note 40874 added to function.imagecopyresampled
| From: | mike at csim dot net | Date: | Wed, 17 Mar 2004 18:53:35 +0000 |
| Subject: | note 40874 added to function.imagecopyresampled | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-66972@lists.php.net to get a copy of this message | ||
I was certain that image resampling could be faster, so I ran two test on my PII 400 computer
comparing both GD2 (PHP4.3.1) and ImageMagick, a free set of image functions you can find here: http://www.imagemagick.org . Both tests resized a set of 10
photos 3.2MP (2048x1536) in size. On the first test, I created two thumbnails for each photo, one
700 pixels in width and another at 120 pixels in width. On the second test, I created just one
thumbnail, 120 pixels in width. Time was counted in "minutes.seconds."
TEST#1 -- IMAGEMAGICK*
------------------------------------------------------
METHOD TIME IMAGE QUALITY
thumbnail.........1.33 good
sample............0.24 bad
resize............1.33 good
size/geometry.....0.42 good
TEST #1 -- GD2 (PHP)
------------------------------------------------------
METHOD TIME IMAGE QUALITY
Imagecopyresampled 1.57 good
TEST#2 -- IMAGEMAGICK*
------------------------------------------------------
METHOD TIME IMAGE QUALITY
thumbnail.........0.26 good
sample............0.19 bad
resize............1.13 good
size/geometry.....0.06 good
TEST #2 -- GD2 (PHP)
------------------------------------------------------
METHOD TIME IMAGE QUALITY
Imagecopyresampled 0.56 good
*ImageMagick Command Methods:
thumbnail........convert -thumbnail $targetSize $sourceFile $targetFile
sample...........convert -sample $targetSize $sourceFile $targetFile
resize...........convert -resize $targetSize $sourceFile $targetFile
size/geometry....convert -size $targetSize $sourceFile -geometry $targetSize $targetFile
CONCLUSIONS:
------------------------------------------------------
There were four different imagemagick commands I tried out in all. Overall, the winner came out to
be the imagemagick size/geometry command. This method beat out PHP by a good margin, creating
thumbnails in about 1/3 the time it took PHP with similar quality in the first test, and then being
truly quick on the second test by creating thumbnails in about 1/10 the time.
Imagemagick seems to increase its performance compared to PHP when creating a smaller thumbnail
versus a relatively large thumbnail, as seen by test #2 versus test #1. The fraction of the time
it takes for imagemagick to create smaller thumbnails (based on these results) makes ImageMagick
almost necessary for dynamically created thumbnail galleries that need to trim resources, or at
least until the Imagecopyresampled function is updated.
----
Manual Page -- http://www.php.net/manual/en/function.imagecopyresampled.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+40874
Delete -- http://master.php.net/manage/user-notes.php?action=delete+40874&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+40874&report=yes
Search -- http://master.php.net/manage/user-notes.php