Rubblewebs

THESE CODES ARE PROVIDED FOR AN EXAMPLE OF HOW TO USE IMAGEMAGICK WITH PHP. CARE SHOULD BE TAKEN WHEN ACCEPTING USER INPUT.

I TAKE NO RESPONSABILTY FOR ANY PROBLEMS THAT MAY OCCURE WHEN USING ANY OF THIS CODE.

IT IS UP TO YOU TO SECURE THE CODE AND VALIDATE USER INPUT.

Speed comparisons

I thought I would try some speed tests and the results are below; the images were ones I found on my hard drive - nothing special about them. There are only one lot of results for each image below but I ran the tests a few times and there was not a great difference in the results.

Some later speed tests including Imagick in a pdf

Using a 0.8MB jpg image

Method Time seconds File size Width x height
Original image
853789 1667 x 2500
Imagick0.4310619831097052 100 x 149
Imagemagick thumbnail0.5731050968177074 100 x 150
Imagemagick thumbnail and the "size hint"0.2932531833656951 100 x 150
Imagemagick resize1.3154339790315992 100 x 150
GD2.128553867345416 100 x 149

Note: GD failed with a memory error at any images over this size. I assume I could allocate more memory but it shows ImageMagick uses less memory ?

Using a 2.8MB jpg image

Method Time seconds File size Width x height
Original image
2962005 1667 x 2500
Imagick0.56925892829920539 100 x 149
Imagemagick thumbnail0.71359992027320602 100 x 150
Imagemagick thumbnail and the "size hint"0.20453691482520260 100 x 150
Imagemagick resize1.4631938934329484 100 x 150
GD2.228406906134986 100 x 149

Using a 1.26MB png image

Method Time seconds File size Width x height
Original image
1330464 647 x 476
Imagick0.19988203048715889 100 x 73
Imagemagick thumbnail0.24404096603438564 100 x 74
Imagemagick thumbnail and the "size hint"0.22566890716638564 100 x 74
Imagemagick resize0.23211002349938187 100 x 74
GD0.42018103599513157 100 x 73

Note: For some reason GD did not retain the transparency