Did you know that you can navigate the posts by swiping left and right?

PHP Image Benchmarks, GD Vs. Image Magick

22 Mar 2009 . category: blog . Comments
#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.


James Armes is a software engineer and open source enthusiast from central Pennsylvania.