Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: PHP and Image Magick
05-06-2004, 06:21 AM #1
- Join Date
- Apr 2004
- Thanked 0 Times in 0 Posts
PHP and Image Magick
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 #2
- Join Date
- May 2002
- Perth Australia
- Thanked 92 Times in 90 Posts
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
image magick has several executables (depending on what you are doing) , convert , combine , composite , mogrify etcPHP Code:
/*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" ) ;
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 ?PHP Code:
remember that running any system command is dangerous & you should always escape your arguments .. see escapeshellcmd() for more info
Last edited by firepages; 05-06-2004 at 08:20 AM.
MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)