Page 1 of 2
[Need] Script that reads img size/name and creates .txt file
Posted: Thu Apr 16, 2009 1:41 pm
by Tormentor667
Okay, I am absolutely no programmer but I am sure that for someone who is a programmer, this isn't that hard to do. I even heard that a php script is able to produce something like this. So what I need is the following: A script that creates a TEXTURES lump making all the textures in my folder ("patches") for example scaled down to half their size. My code for one TEXTURES entry would look like this:
Code: Select all
texture BRICK312, 256, 256
{
XScale 2
YScale 2
Patch BRICK312, 0, 0
{
}
}
In this case the script actually found one texture, a file called BRICK312.PNG with the dimensions of 256x256 pixels. Now, in my /patches folder, there are about 1200 textures which do exactly need the same TEXTURES code to be scaled down half the size (only difference is texture name, texture dimension, patch name which is texture name). I could do this manually but that would take me several hours as I am not such a fast writer. And I guess I will even need some more textures in the future and typing that manually is an evil job.
So what I need is simply a tool that reads out the FILENAME and the DIMENSIONS of each file in a directory and then produces me a nice little TEXTURES lump. Anyone able to do that?
Re: [Need] Script that reads img size/name and creates .txt file
Posted: Thu Apr 16, 2009 1:56 pm
by Rachael
I'll give it a shot, but chances are someone else will get something done a lot faster than I will. I would need to familiarize myself with the .PNG format, first.
Re: [Need] Script that reads img size/name and creates .txt file
Posted: Thu Apr 16, 2009 2:59 pm
by Skippy
Torm, I've knocked a quick n' dirty PHP script that will do this for you if you have a way of running it from your local machine (a local web server, for example)?
I had a great batch file written, then I realized you wanted variable image dimensions as well.

Re: [Need] Script that reads img size/name and creates .txt file
Posted: Thu Apr 16, 2009 4:18 pm
by Rachael
Done. These 2 files will need to be put together, PNG.EXE is a quickbasic program that grabs the PNG dimensions right out of the file. If the file does not conform to standards (and by darn well it should!) this program will fail. The program is DOS, and as a result requires shortened file names - you don't have to worry about this, the batch file automatically shortens them for you.
The program that does the magic is process.cmd - this is the file that you will use. Be sure to edit it, first. Of particular importance are lines 3 & 4:
Code: Select all
set OutFile=textures.auto.txt
set Process=patches\*.png
Outfile is your textures lump - you can specify an absolute path, or one relative to the script. In its current form it outputs to "textures.auto.txt" in its current directory. You can replace that with "C:\games\doom\project\textures.txt" if you want - however, make sure the file does not exist, or it will exit with an error. (It will not let you overwrite an existing file)
Process is almost the same thing, except it specifies where and what files to find. This particular batch program will only read .png files, so don't try and get it to read .lmp's, it won't work. Again, absolute path, or relative, both are accepted.
Afterward, double click the process.cmd file, and boom, there's your textures lump.
You can edit the code in the :maketexture routine of process.cmd file to affect how it outputs the file, so if you need to change something later on, you should be able to.
Re: [Need] Script that reads img size/name and creates .txt file
Posted: Thu Apr 16, 2009 11:32 pm
by Tormentor667
Amazing, thx alot

I can't try it yet as I am at work but I am sure this will exactly do what I need

Re: [Need] Script that reads img size/name and creates .txt file
Posted: Fri Apr 17, 2009 10:36 am
by Apothem
Nice! I thought this would be more complicated... Heh, I guess I was wrong.
Re: [Need] Script that reads img size/name and creates .txt file
Posted: Fri Apr 17, 2009 11:11 am
by Rachael
Hmm, I never thought it would be downloaded 5 times, though, either. ^^
Re: [Need] Script that reads img size/name and creates .txt file
Posted: Fri Apr 17, 2009 12:02 pm
by phi108
Thanks SoulPriestess! This will definitely save time!
EDIT: And the textures entry doesn't need the
{
}
After the patch entry unless you do things to the patch. I guess that would save some bytes in the textures lump.
Re: [Need] Script that reads img size/name and creates .txt file
Posted: Fri Apr 17, 2009 12:53 pm
by Rachael
I know, I put them there because that's what he wanted in his example. If he wants to remove them, he can.
Re: [Need] Script that reads img size/name and creates .txt file
Posted: Thu Jan 21, 2010 2:49 pm
by Nash
Bump.
png.exe does not work in Windows Vista 64 bit. Does anyone know of a similar program that works in 64 bit?
Re: [Need] Script that reads img size/name and creates .txt file
Posted: Thu Jan 21, 2010 5:05 pm
by Enjay
If you have DOSBOX installed, and if it is just a DOS exe (which Eruanna said it was, so presumably it is), it should work under DOSBOX.
Re: [Need] Script that reads img size/name and creates .txt file
Posted: Thu Jan 21, 2010 8:28 pm
by Nash
Okay, png.exe DOES run in DOSBox, but now there are two problems...
1) process.cmd will not run in DOSBox. This is where all the actual scripting happens... png.exe is useless if this won't run as well!
2) Even if it did, having to mount my GZDoom project directory is kind of a chore. I wish I could just write click into any directory that's open in Windows Explorer and have some kind of "mount DOSBox to this directory" or something. I have something similar installed for command prompts ("open command prompt here")...
I need this automation... typing up TEXTURES definitions for hundreds of textures manually is very clumsy...
Re: [Need] Script that reads img size/name and creates .txt file
Posted: Fri Jan 22, 2010 4:30 am
by Nash
Sorry for the double post but I'm starting to get a little desperate...
Would any of the tools found on
http://gnuwin32.sourceforge.net/packages/pngutils.htm be a suitable substitute for SP's png.exe?
Re: [Need] Script that reads img size/name and creates .txt file
Posted: Fri Jan 22, 2010 4:52 am
by carlcyber
@Nash:
Do you have .NET Framework on your computer? If so, you can write a small program based on it to do this for you easily.
Re: [Need] Script that reads img size/name and creates .txt file
Posted: Fri Jan 22, 2010 5:03 am
by Nash
Yes I do... unfortunately I have absolutely no idea how to write such a program... :S