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).
Image Magick: 0.851119382381
Image Magick: 0.873931562901
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.