[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
Tormentor667
Posts: 13554
Joined: Wed Jul 16, 2003 3:52 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia (Modern GZDoom)
Location: Germany
Contact:

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

Post 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?
User avatar
Rachael
Posts: 13914
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

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

Post 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.
User avatar
Skippy
Posts: 695
Joined: Sun Nov 20, 2005 9:57 am
Location: Belfast, NI

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

Post 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. :|
User avatar
Rachael
Posts: 13914
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

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

Post 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.
Attachments
Torm'sTool.zip
(22.72 KiB) Downloaded 156 times
User avatar
Tormentor667
Posts: 13554
Joined: Wed Jul 16, 2003 3:52 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia (Modern GZDoom)
Location: Germany
Contact:

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

Post 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 :)
User avatar
Apothem
Posts: 2070
Joined: Sat Nov 29, 2003 7:13 pm
Location: Performing open heart surgery on an ACS compiler.

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

Post by Apothem »

Nice! I thought this would be more complicated... Heh, I guess I was wrong.
User avatar
Rachael
Posts: 13914
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

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

Post by Rachael »

Hmm, I never thought it would be downloaded 5 times, though, either. ^^
User avatar
phi108
Posts: 976
Joined: Sat Dec 01, 2007 6:28 pm

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

Post 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.
User avatar
Rachael
Posts: 13914
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

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

Post 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.
User avatar
Nash
 
 
Posts: 17484
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 »

Bump.

png.exe does not work in Windows Vista 64 bit. Does anyone know of a similar program that works in 64 bit?
User avatar
Enjay
 
 
Posts: 26935
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

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

Post 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.
User avatar
Nash
 
 
Posts: 17484
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 »

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...
User avatar
Nash
 
 
Posts: 17484
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 »

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?
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 »

@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.
User avatar
Nash
 
 
Posts: 17484
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 »

Yes I do... unfortunately I have absolutely no idea how to write such a program... :S
Locked

Return to “Editing (Archive)”