ImageMagick is probably the best option we have when dealing with image resizing, croping and other small editing jobs that we need when working with image uploads.
As I am running a photography website, where community members are sometimes uploading images straight out of their digital cameras, I came across the following problem:
Digital cameras usually add a lot of extra information in the EXIF section of the JPEG file (regarding camera type, camera settings or the exposure conditions under which the shot was taken). When creating thumbnails for images, using the resize or crop functions from ImageMagick, all this extra information is kept inside the resized thumbnail, adding significant overhead to the resulting file. For instance a small thumbnail 48 by 48 px (like a member’s avatar picture) could take over up to 40 Kb if the file contains EXIF information, instead of abou 8 Kb without EXIF. Considering you could have about 50 avatars beeing loaded on a page, reducing the size of the thumbnails could have an important effect on your page loading time.
The solution to this problem is quite trivial. All you have to do is add an extra parameter to your convert command: - strip
So if your convert command looked like this:
exec('convert '.$source_file.' 48x48 '.$destination_file.'');
The stripped version would be:
exec('convert '.$source_file.' -strip 48x48 '.$destination_file.'');
RSS feed for comments on this post · TrackBack URI
Leave a reply