[Need] Script that reads img size/name and creates .txt file

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
User avatar
InsanityBringer
Posts: 3392
Joined: Thu Jul 05, 2007 4:53 pm
Location: opening the forbidden box

Re: [Need] Script that reads img size/name and creates .txt file

Post by InsanityBringer »

When I get home from finals today I could try to do it. Only problem is I have no idea how to make it handle multiple files, but I could probably modify Eruanna's .CMD file to just run my program.
carlcyber
Posts: 163
Joined: Thu Jan 27, 2005 1:04 am

Re: [Need] Script that reads img size/name and creates .txt file

Post by carlcyber »

Heh, this is a program that should meet you needs. Everything is hard-coded. If you want t change any part, you need to edit and recompile the source (using Visual C# 2008 or above and open "Image2Textures.sln", there are free express versions from MS).

Usage: Place the executive under the same directory of the png images you want it to do for you. It also scans images under all subdirectories.
Attachments
Image2Textures.zip
An alternative for anyone who has .NET Framework
(6.13 KiB) Downloaded 67 times
User avatar
Grubber
Posts: 1031
Joined: Wed Oct 15, 2003 12:19 am
Location: Czech Republic
Contact:

Re: [Need] Script that reads img size/name and creates .txt file

Post by Grubber »

Any scripting thread wouldn't be complete without a nice bash one-liner:

Code: Select all

for f in *.png; do dim=(`identify -format '%w %h' "$f" 2>/dev/null`); if [ $? -ne 0 -o "x${dim[0]}" = "x" ]; then continue; fi; name=`basename "${f%.*}" | tr [a-z] [A-Z]`; printf 'texture %s, %d, %d\n{\n   XScale 2\n   YScale 2\n   Patch %s, 0, 0\n   {\n   }\n}\n' "$name" ${dim[0]} ${dim[1]} "$name"; done > textures.txt
(for all you *nix geeks out there, works with any image format, requires ImageMagick)
User avatar
Nash
 
 
Posts: 17506
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: [Need] Script that reads img size/name and creates .txt file

Post by Nash »

carlcyber wrote:Heh, this is a program that should meet you needs. Everything is hard-coded. If you want t change any part, you need to edit and recompile the source (using Visual C# 2008 or above and open "Image2Textures.sln", there are free express versions from MS).

Usage: Place the executive under the same directory of the png images you want it to do for you. It also scans images under all subdirectories.
Thanks carl. I always knew I could rely on you. :) The hardcoded stuff doesn't bother me... I guess I can just use standard Search and Replace functions in my text editor if I wanted to quickly change the resulting output.

The most important thing is that it's saved me from typing hundreds of texture definitions from scratch. The output is more than 5000 lines in length - I could NOT have done it manually!

Thanks again. :)
User avatar
Ceeb
Posts: 5125
Joined: Wed Jun 11, 2008 4:07 pm
Location: Castle Wut

Re: [Need] Script that reads img size/name and creates .txt file

Post by Ceeb »

I see all this AFTER I write over 6000 lines of the shit manually... :roll:
Locked

Return to “Editing (Archive)”