I was interested in expanding Bonzo’s speed tests to include MagickWand For PHP. Specifically I wanted to compare Imagick vs. MagickWandForPHP. I wasn’t interested in comparing functionality (which differs between the two extensions) – I only wanted to know which one was faster.
Test were run timing the production of a 200x200 thumbnail from a larger jpg, using various methods:
- MagickWand - thumbnail using scale
- MagickWand - thumbnail using resize
- Imagick - thumbnail using scale
- Imagick - thumbnail using resize
- Imagick - thumbnail using thumbnailImage
- convert –resize
- convert -thumbnail
- convert –thumbnail with jpg hint
- GD - thumbnail using resize
Results:
Calling the binary program is generally the slowest as we would expect.
MagickWand for PHP and Imagick are identical in speed (in this test).
“ScaleImage" is significantly faster (1.3 x) than “ResizeImage” although this may not be true at all image sizes (e.g. larger image may give different results?)
In some cases calling the binary is approx the same time as using an extension. However when the jpg hint (i.e. the "-define jpeg:size=200x200" option) is used, exec(convert) is a whopping 3.5 x faster (and 2.5 x the speed of either Imagick or MWforPHP !).
GD is generally faster than ImageMagick but then we expect that – we are using ImageMagick for its quality and functionality!
Question 1: what’s the difference between ResizeImage and ScaleImage? I don’t know – perhaps it uses a “simpler” filter? Further testing might be required to see if there is a difference in quality between the two methods.
Question 2: why is the “jpg hint” option to “convert” sooo much faster, and is there any way to use this option in MagickWand for PHP or Imagick?
Of course this is only one (very) restricted test, and may not be representative of overall performance, but it’s the test in which I was interested.
Test procedure and detailed results are here: http://php-4-business.co.uk/scratchpad/speed_tests.pdf
Speed tests - Imagick vs MagickWand for PHP
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Speed tests - Imagick vs MagickWand for PHP
Scale uses a simpler algorithm that just averages blocks of pixels. Resize uses more complicated methods to avoid aliasing artifacts.Question 1: what’s the difference between ResizeImage and ScaleImage? I don’t know – perhaps it uses a “simpler” filter? Further testing might be required to see if there is a difference in quality between the two methods.
Because it reads in just enough of the image as needed, though I am not an expert on this.Question 2: why is the “jpg hint” option to “convert” sooo much faster, and is there any way to use this option in MagickWand for PHP or Imagick?
see
http://www.imagemagick.org/Usage/formats/#jpg_read
You may also be interested in some other speed tests. See viewtopic.php?f=4&t=16779
Re: Speed tests - Imagick vs MagickWand for PHP
Thanks for your reply.
It had been suggested that MagickWand for PHP was faster because "it was closer to the IM API"; in practice this is not true (in these tests) and there is no difference between them. In which case I will use Imagick since its usage is somewhat more intuitive IMO.
Ahh that makes sense. So "scale" is probably a no-no then. In which case using either of the PHP extensions is (in this test at least) only 4% (1/100th second) faster than using the binary via exec() (although rather more secure in server terms).fmw42 wrote:Scale uses a simpler algorithm that just averages blocks of pixels. Resize uses more complicated methods to avoid aliasing artifacts.
Yes it was those tests by Bonzo which piqued my interest. I expanded them to include MagickWand for PHP which Bonzo didn't cover, so I could see if there was any difference between MagickWand for PHP and Imagick.You may also be interested in some other speed tests. See viewtopic.php?f=4&t=16779
It had been suggested that MagickWand for PHP was faster because "it was closer to the IM API"; in practice this is not true (in these tests) and there is no difference between them. In which case I will use Imagick since its usage is somewhat more intuitive IMO.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Speed tests - Imagick vs MagickWand for PHP
The only problem with IMagick is that is has not been maintained and upgraded in a while, so there may be a number of functions that you can do by PHP exec (using command line syntax) that you cannot do with IMagick (my understanding). However, if all you want is to use it for resizing and basic things, then it should be fine. Be sure you are using v3.x of IMagick and a current version of IM.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Speed tests - Imagick vs MagickWand for PHP
For more on the differences between resize operators see..
IM Examples, Resize
http://www.imagemagick.org/Usage/resize/
IM Examples, Resize
http://www.imagemagick.org/Usage/resize/
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/