Omar Shamali

GdImage VS Imagick PHP Libraries Performance Benchmark of Reading Image Width

Author: Omar Shamali
Writing Date:

The whole story began when I needed to convert images from types other than JPEG, PNG..etc that are supported with GD Library. Before depending fully on Imagick for everything not only conversion, I decided to make benchmarks.

Number of Different Tests

Surprisingly, I stopped after one test for getting shocked of the results. Maybe I will do further tests in the future.

The Test Focus

The test focused on a very simple task, which is just to get the image file width.

Test Results

GDImage crushed Imagick in this test, GdImage is faster by at least ten times in getting image width.

Test Algorithm

Use the most direct methods in order to get specific image's width, without actually reading or fully loading the image.

Put the reading width methods inside for loops of 10000 cycles.

Result in Numbers

  Process Time
GD Image 0.0592770576 Seconds
Imagick 1.2443468571 Seconds

Test Code in PHP


    $final=round((microtime(true) - $___time_started),10);

    echo $final.'<br><br>';



        $imagick=new Imagick;

    $final=round((microtime(true) - $___time_started),10);
    echo $final;

Test Environment

PHP version 8.1