View Full Version : PHP and Image Magick
05-06-2004, 06:21 AM
Hi, i need an example script on how to use PHP and Image Magick together.
If anybody can let me know where i can find something like that, I'd greatly appreciate it.
05-06-2004, 08:17 AM
unless you mean the PECL image_magick extension (incomplete and a pain to get working) ... you basically runa system command assuming imagemagick is installed on the system using exec() or system() etc
e.g. convert tiff to jpg
/*where are imagick executables?*/
$imagick_path = '/usr/local/imagick/bin/convert' ;
/*this file must exist!*/
$infile = '/home/www/incoming/image.tiff' ;
/*will be created!*/
$outfile = '/home/www/images/image.jpg' ;
exec( "$imagick_path $infile $outfile" ) ;
image magick has several executables (depending on what you are doing) , convert , combine , composite , mogrify etc
you just need to find where these exectuables live on your system and call them , on some systems they will be in the PATH and can just be called directly exec("convert $img1 $img2") ; etc , if not you can find them using `which $program` if you have SSH/telnet .. if not
if convert does not work or make sense (on win32 there is DOS convert !) try mogrify which is probably unique to image magick ?
remember that running any system command is dangerous & you should always escape your arguments .. see escapeshellcmd() (http://www.php.net/escapeshellcmd) for more info
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.