Re: ImageMagick, gd and other hellish incantations

From: Date: Sun, 25 Jun 2000 07:37:57 +0000
Subject: Re: ImageMagick, gd and other hellish incantations
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-2959@lists.php.net to get a copy of this message
> So, my first question is what role does ImageMagick play in PHP's > configuration/installation, since it does look for it? I haven't seen any > ImageMagick specific functions, nor have I seen any configuration options > (such as --with-imagemagick or the like). None, ImageMagick support is broken and deprecated. > To me, gd is turning out to be a nightmare. I usually create all of my > graphics in the usual way(s), and, as of now, all I'm looking for is a way > to create _real_ thumbnails on the fly that is as portable as possible. > Sounds easy, but it ain't lookin' so easy. ;-) /* globals */ $theight=96; $djpeg = "/usr/bin/djpeg"; /* decompresses a jpeg to ppm format */ $cjpeg = "/usr/bin/cjpeg"; /* compreses a ppm to jpeg format */ $pnmscale = "/usr/bin/pnmscale"; /* scales a ppm image */ $giftopnm = "/usr/bin/giftopnm"; /* convert a gif to ppm format */ $ppmtogif = "/usr/bin/ppmtogif"; /* convert a ppm to gif format */ $ppmquant = "/usr/bin/ppmquant"; /* colour quantize a ppm image */ $pnmpad = "/usr/bin/pnmpad"; $shadow = "/usr/local/bin/shadow"; /* Put a drop-shadow on a GIF */ /* * The thumbnail function uses the pnmscale program from * the popular Netpbm image manipulation tools package * to create a thumbnail of the given image. If a thumbnail * already exists for the image, the function simply returns. */ function thumbnail($filename) { global $theight, $djpeg, $cjpeg, $pnmscale, $giftopnm, $ppmtogif, $ppmquant, $pnmpad, $shadow; $tdir = dirname($filename)."/thumbnails"; /* thumbnail directory */ if(!filetype($tdir)) { if(!@mkdir($tdir,0777)) { echo "Unable to create $tdir directory - check permissions<br>\n"; return; } } $tfile = $tdir."/".basename($filename); /* thumbnail file */ $tfile = ereg_replace("\.[^\.]+$",".gif",$tfile); if(!filesize($tfile)) { if(eregi("\.gif$",$filename)) { /* Look for .gif extension */ exec("$giftopnm $filename | $pnmscale -height $theight | $pnmpad -white -l6 -b6 | $ppmquant 248 | $ppmtogif | $shadow > $tfile"); } elseif(eregi("\.jpe?g",$filename)) { /* Look for .jpg or .jpeg extension */ exec("$djpeg $filename | $pnmscale -height $theight | $pnmpad -white -l6 -b6 | $ppmquant 248 | $ppmtogif | $shadow > $tfile"); } else { /* not a GIF or JPG file */ return(""); } } return($tfile); } -Rasmus

« previous php.general (#2959) next »