Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    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.

  • #2
    Super Moderator
    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

    PHP 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" ) ;
    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

    PHP Code:
    ('which convert',$yaks);
    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() for more info
    Last edited by firepages; 05-06-2004 at 08:20 AM.
    resistance is...

    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)


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts