Batch .png trim and output offsets?
BlitzMax Forums/BlitzMax Programming/Batch .png trim and output offsets?
| ||
Hi all, does anyone have an app (or BlitzMax code) that will batch trim png files of transparent space (ideally with a 1 pixel border to avoid weirdness) and that outputs all the drawing offsets in a text file? That would be super useful. I already have Texture Packer Pro and I wonder if it can do that via command line but I haven't figured it out yet. I don't actually want to make a big texture, just trim a whole load of pngs. Thanks! |
| ||
With linux you could do: convert img.png -trim -identify +repage img.trimmed.png Output: img.png PNG 800x600=>600x500 800x600+100+50 8-bit DirectClass 0.000u 0:00.004 (so it includes the offset). Next to this I just prepared a simple trimmer for you. It utilizes some files of my "Dig"-framework, so just download the framework and open "samples/imagehelper/imagehelper.trimimage.bmx" Framework: https://www.github.com/GWRon/Dig.git Sample output (you could adjust to your needs): $ ./imagehelper.trimimage gfx Input dir: "gfx" Output dir: "gfx/trimmed" Processing [10 files] - processing: "gfx/datasheet_general.png" - trimmed: 512,256 -> 364,250 (offset: 0,0 / 363,249) - saved as "gfx/trimmed/datasheet_general.png". - processing: "gfx/dialogue.png" - trimmed: 256,128 -> 248,120 (offset: 0,0 / 247,119) - saved as "gfx/trimmed/dialogue.png". - processing: "gfx/errorbox.png" - trimmed: 295,190 -> 293,186 (offset: 2,3 / 294,188) - saved as "gfx/trimmed/errorbox.png". - processing: "gfx/figuregenerator.png" - trimmed: 512,500 -> 504,462 (offset: 0,0 / 503,461) - saved as "gfx/trimmed/figuregenerator.png". - processing: "gfx/logo.png" - trimmed: 512,256 -> 497,242 (offset: 5,4 / 501,245) - saved as "gfx/trimmed/logo.png". - processing: "gfx/logo_small.png" - trimmed: 128,64 -> 123,60 (offset: 2,1 / 124,60) - saved as "gfx/trimmed/logo_small.png". - processing: "gfx/screen_menu.png" - trimmed: 800,600 -> 800,600 (offset: 0,0 / 799,599) - saved as "gfx/trimmed/screen_menu.png". [...] bye Ron |
| ||
If Texture Packer Pro doesn't have the ability to batch multiple images without combining them into a texture, couldn't you write a BlitzMax program which would produce a batch file to run TPP on a single image over and over again? |
| ||
@Derron, great thanks for that!! @Gabriel only problem is it wouldn't have all the output data (offsets etc) in the same file, I'd end up with lots of files. |
| ||
@multiple output files ... Load all in and write content to a single file. Think you are experienced enough to achieve this ;-) Bye Ron |