ImageMagick Help Request

ImageMagick Help Request

Hi, folks. I've been doing a lot of manual select/copy/new/paste/save to split up spritesheets recently, and remembered reading something about pfunked's workflow including an ImageMagick command. I've been through a good amount of the documentation and determined it will definitely solve my problem, but have also determined that I'm near-useless on the command line.

I'm looking for two commands right now: one to replace a color with transparency and one to split a file into XxY blocks. Pretty simple on their own (and I had finicky versions working, even if I didn't fully understand them), but it would make them ten times as helpful if I could use them for batches. For example, cd'ing into a directory and performing the operation on every file matching *.png.

 

The command I used for transparency was

mogrify /path/to/spritesheet.png -matte -fill none -draw 'color 0,0 replace'

(Replace pixels the same color as pixel 0,0 with fill of 'none'.)

 

The command I used for creating tiles from an image was

convert /path/to/spritesheet.png -crop 32x32 +repage +adjoin tile_%02d.png

 

Unfortunately, I don't know how to get these working in a batch scenario, and #2 seems especially difficult because the resulting tile names would be the same for each image I split. (Make a new folder named the same as the parent image, maybe?)

Any help on this would be greatly appreciated, as my bash experience doesn't go much past copy/paste. =/