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.
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
Method | Time seconds | File size | Width x height |
---|---|---|---|
Original image | 853789 | 1667 x 2500 | |
Imagick | 0.431061983109 | 7052 | 100 x 149 |
Imagemagick thumbnail | 0.573105096817 | 7074 | 100 x 150 |
Imagemagick thumbnail and the "size hint" | 0.293253183365 | 6951 | 100 x 150 |
Imagemagick resize | 1.31543397903 | 15992 | 100 x 150 |
GD | 2.12855386734 | 5416 | 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 ?
Method | Time seconds | File size | Width x height |
---|---|---|---|
Original image | 2962005 | 1667 x 2500 | |
Imagick | 0.569258928299 | 20539 | 100 x 149 |
Imagemagick thumbnail | 0.713599920273 | 20602 | 100 x 150 |
Imagemagick thumbnail and the "size hint" | 0.204536914825 | 20260 | 100 x 150 |
Imagemagick resize | 1.46319389343 | 29484 | 100 x 150 |
GD | 2.22840690613 | 4986 | 100 x 149 |
Method | Time seconds | File size | Width x height |
---|---|---|---|
Original image | 1330464 | 647 x 476 | |
Imagick | 0.199882030487 | 15889 | 100 x 73 |
Imagemagick thumbnail | 0.244040966034 | 38564 | 100 x 74 |
Imagemagick thumbnail and the "size hint" | 0.225668907166 | 38564 | 100 x 74 |
Imagemagick resize | 0.232110023499 | 38187 | 100 x 74 |
GD | 0.420181035995 | 13157 | 100 x 73 |
Note: For some reason GD did not retain the transparency