Issue
I'm generating thumbnails from images automatically with the PHP GD library.
I then save the resized image to a file using imagejpeg()
with 95% quality.
When I output this file using echo file_get_contents($file)
, the filesize of the image is always about 2.5 - 4 times as large compared to when I directly output the resized image to the browser using imagejpeg($resource_handle)
.
Google PageSpeed also tells me images could be compressed by 75%, which confirms the 1/4 ratio noticed.
What could be the reason for this?
Solution
I found the manual (http://php.net/manual/en/function.imagejpeg.php) mentions that the default (without passing the quality argument) quality setting is around 75%.
This explains why outputting an image directly without any other arguments passed to imagejpeg()
results in a smaller image then when setting a quality higher than 75 manually.
Answered By - Bastiaan ten Klooster Answer Checked By - Willingham (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.