ImageMagick Info (attn: Matt Zimmerman)
Chris Snyder
chris at psydeshow.org
Wed May 28 16:13:38 EDT 2003
The topic of ImageMagick came up at last night's meeting, as a way for
PHP to work with images.
http://www.imagemagick.org/
I recommend it highly, as it is meant to be scriptable via the command
line (and therefore via PHP shell_exec()). It's really a suite of
commands-- the ones you're probably most interested in are convert and
identify.
For instance, when someone uploads an image to fotola.com, here's the
call that resizes and/or rotates it, strips any IPTC or APP16 headers,
and compresses it at medium compression:
$command= "/usr/local/bin/convert jpeg:$tempfile -rotate $rotate
-geometry \\"500x500>\\" -quality 95 +profile \\"*\\" jpeg:$filename"
exec($command);
- $rotate is some number of degrees
- the > after 500x500 means resize only if the image doesn't fit in the
500x500 box
- resizing is automatically proportional
- the +profile "*" option strips all extra info from the image (making
it 2-3KB smaller)
- Be sure to properly escape all user input to exec() calls!!!
There is a PHP extension (coauthored by Michael Montero of Community
Connect, no less) that makes ImageMagick accessible to PHP without the
exec calls, but I haven't used it yet-- might be much easier.
http://pear.php.net/package-info.php?pacid=76
chris.
More information about the talk
mailing list