I really should know better by now. I really ought to. My hand has been burned at least a dozen times by this, and yet I keep reaching for that protruding handle.
I upgraded ImageMagick again.
<moist towel to the forehead; steaming cup of cocoa held to my lips by concerned friends>
I don't know what possessed me to do it. Maybe the promise that the newest version contains better options to strip out IPTC and XML headers from JPEGs, so Internet Explorer doesn't choke and die upon trying to read images created by obscure software like Adobe Photoshop 7. (Magic command: mogrify +profile \* blah.jpg) Maybe it was the simple fact that my installed copy was a full minor version older than the current release, which always nags at me; no matter how well something is working right now, no matter how little poking and/or prodding it requires, I just can't leave well enough alone if there's a new and better version available. (About the only thing I've been able to prevent myself from upgrading is my scanner software, because even my must-upgrade-everything reflexes can't overcome the lessons I've so painfully learned on that front.)
Some years ago, I upgraded ImageMagick, only to find that all my server-side code-- which automatically generated thumbnails from uploaded images-- had started spewing all over itself, chewing up CPU, and creating some of the most hideously deformed thumbnail images ever. See, I was used to using the following command:
# mogrify -geometry 60x999 blah.s.jpg
...to scale the thumbnail proportionally to 60 pixels wide, with the height being whatever is consistent with the same aspect ratio and 60 pixels wide. A 600x400 picture would become a 60x40 thumbnail. The "999" was a special key number, you see-- it told ImageMagick to scale proportionally. Apparently they'd never bothered to code a proper option for only specifying one dimension, so this hack was the best they could do.
So I upgraded, and found that my thumnails were now... 60 pixels wide, and 999 pixels tall. They'd removed the special handling.
Now I use "9999" for that command. It's still an awful hack, but at least it isn't chewing up my CPU as it tries to blow everything up to a thousand vertical pixels every time someone uploads something. At least, until they change something else and I have to make it "99999".
So now I install the new version, mentally silencing my inner voice and its dire warnings against I-have-no-idea-what, and my script tries to resize a thumbnail. What should happen, but:
mogrify: No decode delegate for this image format (blah.jpg).
I spent about half an hour on the phone with Chris, a fellow warrior in the image-archives trenches. We do numerous experiments, trying to see whether it was GIF support that had broken (the thumbnail was actually a GIF that I'd renamed to .jpg, for reasons that are too complex to get into here), or if my JPEG library had been eaten by disk moths, or if it required X11 and KDE now in order to run its command-line tools, or whatever stupid-ass thing they'd decided to change about the program this time.
Turned out, though, it wasn't ImageMagick's fault. Sort of. Rather, it was the fault of whoever's in charge of its FreeBSD port, or (to go to the Root Causes), the spate of lawsuits that keep spewing out from every popular image format every time the company that holds the patents on it goes out of business and releases its spore-lawyers in a last-ditch Samson maneuver to rake in whatever money might possibly be in the property. Unisys did it, with GIF (though now they have a powerful new friend; the weird holding company that has the IP for JPEG did it.
And now, apparently so as to cover their ass, the ImageMagick porters have ifdef'd out the support for all the popular image formats, the ones ImageMagick is ostensibly designed to handle. JPEG. TIFF. PNG. PDF. TTF. JPEG2000. LZW-based GIF. Never mind that formats like PNG are specifically designed to be patent-free. Someone commented them out anyway.
We discovered it, incidentally, here:
# convert -list format
Format Mode Description
JPC* rw- JPEG-2000 Code Stream Syntax
JPEG* --- Joint Photographic Experts Group JFIF format (62)
JPG* --- Joint Photographic Experts Group JFIF format
LABEL* r-- Image label
See that "---" where there's supposed to be read/writability? Ain't no JPEG support. And GIF says "LZW disabled", which I guess explains why a GIF I converted changed from 30K to 50K.
So here's what to do, if you're on FreeBSD and want to avoid pain. Before building your ImageMagick port, set up these environment variables:
# setenv WITH_JPEG yes
# setenv WITH_PNG yes
# setenv WITH_TIFF yes
# setenv WITH_HDF yes
# setenv WITH_FPX yes
# setenv WITH_JBIG yes
# setenv WITH_JPEG2000 yes
# setenv WITH_LCMS yes
# setenv WITH_TTF yes
# setenv WITH_WMF yes
# setenv WITH_SVG yes
# setenv WITH_DPS yes
# setenv WITH_PDF yes
Feel free to omit any of these if you don't need them. Also, to get LZW-based GIF:
# setenv USA_RESIDENT yes
Please don't set that variable if you're a terrorist.
Then recompile. And wait for the next version to get rolled into the ports, which will contain a new -strip option, which will replace the hacky old +profile \*. Then upgrade again, and prepare for a whole new generation of pain.