I have photo gallery code that does image re-sizing and thumbnail creation. I use ImageMagick to do this. I ran a gallery page through Google’s Page Speed tool and it revealed that the re-sized images and thumbnails both have about an extra 10KB of data (JPEG files specifically).
What can I add to my scripts to optimize the file size?
ADDITIONAL INFORMATION
I am using the imagick::FILTER_LANCZOS filter with a blur setting of 0.9 when calling the resizeImage() function. JPEGs have a quality setting of 80.
I found this SO question, “Tools for JPEG optimization?“, that has some good information, but the solutions are outside of PHP. Using hints from that question’s solutions I found that there were two lossless optimizations that could be performed:
Both of can be accomplished with
ImageMagickthis way:One image I tested was reduced by 12KB. The 600×450 file went from 63.42KB to 51.42KB, and the 140×105 thumbnail went from 17.98KB to 5.98KB.