PDA

View Full Version : Batch image processing transparency method



The303
14-02-2016, 02:28 AM
So while pursuing an unrelated method on sprites, I have come across a method of fast and efficient batch processing of images with either an alpha channel targa or built-in like PNG that thresholds and converts to pure blue. This is incredibly useful because normally I wasted tons of time dealing with clipping masks, thresholds and collapsing layers in photoshop for just one by-one images. It requires you install imagemagick (http://www.imagemagick.org/script/index.php)

Now I pulled up a folder of mixed PNGs and TGAs with transparency/alpha from years ago when I was making tons of source spraylogos (these are already power of 2 images). I opened up console, went to my dir and put in this for imagemagick:

convert * -compress None -channel alpha -threshold 50% +channel -background #0000ff -alpha background -alpha off -colors 256 bmp3:{img.bmp
(note that * can be changed with *.tga or *.png if you specifically want just those or whatnot.)
http://the303.org/imaeg/goldtconvert1.jpg
Once imagemagick runs its course drag and drop the new BMPs into wally. Also since I specified "{img" on the filename all our images have already been prepared for transparency.
http://the303.org/imaeg/goldtconvert2.jpg
Make your func_wall or func_illusionarys as needed:
http://the303.org/imaeg/goldtconvert3.jpg
Final result.
http://the303.org/imaeg/goldtconvert4.jpg

Note you can also adjust the threshold percentages in your command line to fully eliminate things like shadows. Notice on some there is still a shadow since my originals had a gradient fade. This saved an asston of work.
Also would anyone know a command to preserve original image filenames?

Silencer
14-02-2016, 08:46 AM
Some command-line processing on images is actually very useful sometimes. Especially when dealing with data images like normal maps. Good tutorial!

Also nice memes yo.

AdamR
14-02-2016, 09:43 AM
Nice tutorial.

For those wanting a graphical tool IrfanView (http://www.irfanview.com/) is capable of batch processing images into BMP and TGA format but probably not with the transparency setting ImageMagick can do.



Moved to the tutorials sub-forum. :)

The303
14-02-2016, 03:25 PM
Nice tutorial.

For those wanting a graphical tool IrfanView (http://www.irfanview.com/) is capable of batch processing images into BMP and TGA format but probably not with the transparency setting ImageMagick can do.



Moved to the tutorials sub-forum. :)

Ah thanks for moving, it was late and I was tired and didn't notice I wasn't in tutorials.

Also, speak of the devil, I was just writing a similar method using IRFANVIEW for a friend who had a bunch of old ripped textures he wanted converted to goldsrc easily:
http://www.the303.org/tutorials/gold_texture_px.htm

IRFANVIEWS batch processor is frigging amazing, like just look at all those advanced options. Not as powerful per say as imagemagick but for 90% of tasks its easy and the best.

twitch
22-12-2016, 09:26 AM
Very Helpful! Currently using the irfanview process. Does imagemagik install on windows?