how to execute imagick commands in php?

MagickWand for PHP is an object-oriented PHP interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning MagickWand for PHP.
Post Reply
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Post by Bonzo »

The way I do it is:

Code: Select all

exec("/usr/local/bin/convert cmyk.tif -colorspace gray gray.tif ");
Some php examples at www.rubblewebs.co.uk/imagemagick
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Post by Bonzo »

I found you can use relative paths OK rather than absolute ones. Also I have found that using ../../www/ etc. causes a problem as ImageMagick interperates it as something else.

If you want to use something like ../../www/ put it into a variable instead and use the variable in the exe comand.

Code: Select all

$image_in = "../../var/www/test1.jpg ";
$image_out = "../../var/www/test2.jpg";

exec("/usr/bin/convert $image_in $image_out");
If the code is in the same directory this should work.

Code: Select all

exec("/usr/bin/convert test1.jpg test2.jpg");
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

I thing the original user may have been taking about the "imagick" PECL interface not the command line.

The Only example I have however is just a basic load and output version

Code: Select all

<?
        $handle = imagick_readimage( getcwd() . "/animated.gif" ) ;
        if ( imagick_iserror( $handle ) )
        {
                $reason      = imagick_failedreason( $handle ) ;
                $description = imagick_faileddescription( $handle ) ;

                print "handle failed!<BR>\nReason: $reason<BR>\nDescription: description<BR>\n" ;
                exit ;
        }

        print "Number of frames in image: " . imagick_getlistsize( $handle ) .  "<BR>\n" ;
?>
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
monsters

Post by monsters »

not be a jerk, this section is for magickwand questions, your questions are just imagemagick + php questions

hope you found your answers though.
Post Reply