Page 1 of 1

Is ImageMagick convert faster then imagick php extension?

Posted: 2009-07-28T08:39:44-07:00
by sabater_wb
Hello.
I would like to know if using exec(convert...) is faster than using the imagick extension.

Re: Is ImageMagick convert faster then imagick php extension?

Posted: 2009-07-28T08:45:43-07:00
by magick
There is more overhead associated with using the ImageMagick command-line programs than calling ImageMagick from a script. However, the only way to be sure is to benchmark both (e.g. convert and IMagick).

Re: Is ImageMagick convert faster then imagick php extension?

Posted: 2009-07-28T10:49:50-07:00
by Bonzo
Here are some speed tests I did a year or so ago.
http://www.rubblewebs.co.uk/imagemagick/notes/speed.php

It dpends on what you are doing and you would need to run some tests of your own which is not hard to do.

Re: Is ImageMagick convert faster then imagick php extension?

Posted: 2009-07-28T11:47:04-07:00
by fmw42
Bonzo,

Nice tests. Have you also benchmarked IMagick vs Magickwand for PHP.

I have been curious about the comparisons both with regard to speed and to functionality, although I am convinced that neither IMagick nor Magickwand will have the full functionality (and documentation) that there is when using command line and thus "exec" with PHP.

Re: Is ImageMagick convert faster then imagick php extension?

Posted: 2009-07-28T11:57:31-07:00
by Bonzo
No I have not tried it against Magickwand as I have never used it. I will look into it and see if I can run the tests again.

Like you the reason I prefer to use the comand line is there are a lot more options against Imagick. With the command line you can use every option and build the code as you like but with Imagick and Magickwand you are restricted to what has been written.

Re: Is ImageMagick convert faster then imagick php extension?

Posted: 2009-07-28T12:14:43-07:00
by fmw42
It would be interesting to hear from the creator of IMagick regarding any (speed) tests that he has done and what approximate percent of the full command line capabilities have been implemented.

Re: Is ImageMagick convert faster then imagick php extension?

Posted: 2009-07-28T14:08:08-07:00
by Bonzo
Forgot my new PC does not have Imagick or Magickwand.

I have installed Magickwand Ok and just need to find a suitable example to copy but I can not get Imagick to work. Everytime I enable it in the php.ini file I get an error "Entry point not found".

I will leave this for now until I get some more time tofind the problem.

Re: Is ImageMagick convert faster then imagick php extension?

Posted: 2009-07-29T03:45:29-07:00
by Bonzo
I copied my imagick.dll from my old PC to the new one and it works now.

Run a test 10 times and found the averidge and Imagick was the fastest on a 1mb image, command line with jpg hint next, Magickwand then the command line
On a larger image 3mb it was Command line with jpg hint, Imagick, command line then Magick wand.

Results are here : http://www.rubblewebs.co.uk/TESTS/results.html I will try and tidy them up later and add a GD test ( although I will probably get a memory error ).

Quad core PC running php 5.2.9 via Vista and a XAMPP server.

As you say Fred it would be interesting to get some input from the Imagick developer.

Another reason not to use Imagick and MagickWand is there is another lot of code to learn!

Re: Is ImageMagick convert faster then imagick php extension?

Posted: 2009-07-29T05:32:42-07:00
by Bonzo
Not really sure what I am doing with the Magickwand code but I have changed it from an image size of 100x100 to 100x75 and it takes longer !
Magickwand is the slowest in both tests. May be down to the code I am using:
Magick wand - is there a way to keep the image aspect ratio automaticaly ?

Code: Select all

$resource = NewMagickWand();
MagickReadImage( $resource, $image );
MagickResizeImage( $resource, 100, 75, MW_QuadraticFilter, 1.0 );
magickWriteImage( $resource, "wand.jpg" );
DestroyMagickWand( $resource );
Command line

Code: Select all

exec("convert $image -resize 100x100 command.jpg");
Command line with jpg hint

Code: Select all

exec("convert -size 100x100 $image -resize 100x100 hint.jpg");
Imagick

Code: Select all

$thumbnail = new Imagick( $image );
$thumbnail->thumbnailImage( 100, 0 );
$thumbnail->writeImage( "imagick.jpg" );
GD

Code: Select all

$size = getimagesize( $image );
// Set the new width of the image
$thumb_width = "100";
// Calculate the height of the new image to keep the aspect ratio
$thumb_height = ( int )(( $thumb_width/$size[0] )*$size[1] );
// Create a new true color image in the memory
$thumbnail = ImageCreateTrueColor( $thumb_width, $thumb_height );
// Create a new image from file 
$src_img = ImageCreateFromJPEG( $image );
// Create the resized image
ImageCopyResampled( $thumbnail, $src_img, 0, 0, 0, 0, $thumb_width, $thumb_height, $size[0], $size[1] );
// Save the image as resized.jpg
ImageJPEG( $thumbnail, "gd.jpg" );
// Clear the memory of the tempory image 
ImageDestroy( $thumbnail );
As I thought the GD code crashes on an image over 1mb.

Re: Is ImageMagick convert faster then imagick php extension?

Posted: 2009-07-30T21:17:26-07:00
by fmw42
Thanks for all your hard work. This looks very interesting and useful. I am surprised that Magickwand is so slow as it is an API.

I would be interested if anyone can repeat this with PerlMagick for comparison.