Thursday, January 10, 2008

Update on GD vs ImageMagick

I decided it wasn't fair for me to compare gd and imagemagick when I was calling imagemagick through exec( "convert image.jpg -thumbnail 100x TN_image.jpg" ) so I decided to install the extension for php called imagick.

This had to be installed to PECL, it didn't work on my ubuntu 7.10 by just doing apt-get install php5-imagick.

Nice examples of how to use imagick on Mikko's blog. I couldn't follow his examples though as the version that was installed through PECL didn't have some of the functions he used. Would have been nice to put shadows on my thumbnails though.

Anyways I made the script that creates thumbnails through imagick and compared it to the script in my gallery that uses GD. It seems GD was ahead by just a bit this time, although the quality of the imagick thumbnails were far superior, probably because I had set the GD functions to use less resolution.


From this example the images were really huge (3000x4500 pixels 1.5-2mb), the thumbnails rendered by GD seems pixelated compared to what imagick produced.


Imagick created 12 thumbnails with very nice quality but was 2 seconds slower than GD.

Powered by ScribeFire.


Anonymous said...

Interesting results; it made me try some resizing. I just used 3 images I found on my XP machine and I am using XAMPP. All the images came off a digital camera and were 2.8Mb 3.1Mb & 4.7Mb.

First IM took 2.34015679359 seconds to resize and display the thumbs ( using exec() ).
First time through GD failed with "Fatal error: Allowed memory size of 33554432 bytes exhausted". I halved the image sizes first and tried again this time it took 3.3746240139 seconds to resize and display the thumbs.

Anonymous said...

I think IM was faster in my other test as it had only 3 calls to exec.
If you have more images GD is faster.

Mikko said...

It would be interesting to see the Imagick script you used in these tests.

Anonymous said...

ImageMagick code used ( not Imagick ):

// Setup the maximium width and height for the finished image
$max_width = "200";
$max_height = "90";

// Directory containing the images
$dir = './';

// Sellect all jpg, png and gif images
foreach (glob($dir."{*.jpg,*.JPG,*.gif}",GLOB_BRACE ) as $filename) {

// Get the image size for use in the code
$size=GetImageSize( $filename );

$new_name = $filename;

exec("convert -size {$size[0]}x{$size[1]} $filename -thumbnail $max_widthx$max_height $new_name");


Note: I had to remove my echo part of the code as it "cannot be accepted".

Anonymous said...

simply dropping by to say hi

Zheng junxai5 said...

michael kors outlet clearance
nfl jerseys
adidas running shoes
michael kors outlet online sale
ralph lauren
hollister clothing
coach factory outlet
michael kors outlet
michael kors outlet
coach outlet
michael kors
oakley vault
cheap oakley sunglasses
fit flops
coach factory outlet
michael kors handbags
oakley sunglasses wholesale
ray ban eyeglasses
nike uk
nfl jerseys
louis vuitton bags
tory burch boots
coach factory outlet
tiffany and co
michael kors outlet clearance
coach outlet
michael kors outlet
juicy couture
beats by dr dre
cheap jordans
nike roshe one
coach factory outlet online
ray ban sunglasses
insanity workout
jordan retro 8
coach outlet
ralph lauren home
ray bans
cheap oakley sunglasses
louis vuitton purses