Automating Image Conversion in the Shell
In my map tests (final attempts here) for Drupal's game.module, I needed to convert hundreds of PNG images to GIF format, keeping the transparency relatively in place (though certainly dummied down). Normally I'd do this with OS X's Graphic Converter but I was unable to find the magic words to keep the transparency across conversions. I moved to attempting the feat with GIMP's batch mode and Script-Fu which was working quite well (nearly finished my first-evah Script-Fu) but eventually decided upon ImageMagick's convert
utility, which brought me to something like:
> convert a.png -scale 24x24 b.gif
Which worked well-enough in my "ease" expectations, but not so much on the alpha to single-bit transparency that I needed for my GIF - I always had a black "halo" around the non-transparent parts of the image. I responded with the two command lines below: first we scale, then convert with some extra little flags:
> convert a.png -scale 24x24 b.png > convert b.png -channel A -threshold 80% c.gif
But, after finally figuring out how to properly get PNG alpha transparencies to work within Internet Explorer, I no longer needed GIF images at all, and the final version of the command line became simply:
> mkdir conv > cd source > for i in *; do convert $i -scale 24x24 ../conv/$i; done;
Just an FYI to myself.