I know for a fact that quite a lot of people are using the convert command line utility from PHP using exec or similar execution function. Here is some (micro)benchmarks of using exec convert vs imagick extension. My test directory had 13 jpg images in it.

Here is the script i used with Imagick:

PHP:
  1. <?php
  2. foreach ( new imagick( glob( "/var/www/testimages/new/im/*.jpg" ) )  as $image )
  3. {
  4.     $image->thumbnailImage( 200, null );
  5.     $image->writeImage( "/tmp/th/" . basename( $image->getImageFilename() ) );
  6.     $image->removeImage();
  7. }
  8. ?>

And the script I used with convert:

PHP:
  1. <?php
  2.  
  3. foreach ( glob( "/var/www/testimages/new/im/*.jpg" ) as $image )
  4. {
  5.     exec( "convert -thumbnail 200 ${image} /tmp/th/". basename( $image ) );
  6. }
  7.  
  8. ?>

The scripts produce about identical result images. But the difference is the execution time:

Here is the execution time of the imagick script:

real 0m1.292s
user 0m1.010s
sys 0m0.260s

And the execution time of the convert script:

real 0m2.695s
user 0m2.160s
sys 0m0.510s

I used time php script.php to run these scripts and linux time utility to get the times. The times are ten run averages. It looks like if used from PHP the Imagick extension is about twice as fast as using the convert utility via exec.

THESE ARE MICROBENCHMARKS AND MIGHT NOT REFLECT A REAL WORLD SITUATION!

Bookmark and Share