[Need] Script that reads img size/name and creates .txt file
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.
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.
- 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
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.
Re: [Need] Script that reads img size/name and creates .txt file
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.
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
Re: [Need] Script that reads img size/name and creates .txt file
Any scripting thread wouldn't be complete without a nice bash one-liner:
(for all you *nix geeks out there, works with any image format, requires ImageMagick)
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.txtRe: [Need] Script that reads img size/name and creates .txt file
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.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.
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. :)
Re: [Need] Script that reads img size/name and creates .txt file
I see all this AFTER I write over 6000 lines of the shit manually... 
