PHP Image Benchmarks, GD Vs. Image Magick

22 Mar 2009 | Benchmark, Images, PHP

Earlier this week I ran into an issue resizing bitmap images inside of WorkXpress. We currently use GD for our image resizing needs. Unknown to us, GD has plenty of issues resizing bitmaps, and all of our bitmap files we becoming corrupted. I modified our resize code to use Image Magick if the image is a bitmap and continue using GD for other image types. The next step of course is to do some research and testing to see if we should switch over to Image Magick completely, leaving GD behind.

After doing some research, I found plenty of claims that GD is faster than Image Magick. But how much faster? I was on a quest to find out. I took a rather large jpeg image (3504 x 2336 pixels) and converted it to three other popular formats, png, gif, and bitmap. I then wrote a script that resizes each one to 300 x 200 pixels (png shown below) using both GD and Image Magick. The script performs each resize 100 times and prints out the averages. I wanted to provide a working link to each format’s resize code in action, but GoDaddy does not support Image Magick. The benchmark results were quite interesting, as seen below (results are in seconds).

Resized PNG

GD: 0.572078313828
Image Magick: 0.851119382381

GD: 0.524123055935
Image Magick: 0.873931562901

GD: 0.497557456493
Image Magick: 1.15288033009

GD: 0.00230557203293 (Image Corrupted)
Image Magick: 0.523070528507

As you can see, GD out performed Image Magick by 48-131%, excluding the bitmap results. So it looks like we’ll be sticking with GD for now, with the exception of bitmaps.

comments powered by Disqus

Older · View Archive (34)

vcards In Mozilla Thunderbird

Lately, I have been constantly switching between both operating systems and mail clients. I became quite fond of Kontact, KDE’s PIM suite, long ago. The only thing that stopped me from switching over to it full time was its lack of support for HTML signatures. As of the KDE 4 release of Kontact, support has been added for HTML signatures. I decided to make the switch back to Kontact earlier this week.


Add Viddler Videos To Your Drupal Site

Have a Viddler account and looking to embed videos on your website? You could embed the videos directly into the body of your nodes, but that doesn’t give you as much control as you may desire. You could use CCK and the Embedded Media Field (emfield) module, but that doesn’t support Viddler. Or does it?