When I started working with images in PHP, I learned images should be resized and resampled to reduce file size. I'm taking resizing
here to be reducing an image height and width without intentionally altering image quality and resampling
to be resizing and intentionally altering image quality with imageconvolution() function. When comparing a group of images of the same dimensions, one resampled with PHP, the other not, I noticed not-so-subtle differences in the file sizes. These are my findings for one set of images, and they were similar to the other sets:
Resampled and Resized Image:
- Dimensions: 550 * 366
- File Size: 25.19KB
Resized Image without Resampling:
- Dimensions: 550 * 366
- File Size: 20.89KB
Original Image:
- Dimensions: 4896 * 3264
- File Size: 1.1MB
The resampled image is 4.3KB
bigger than the non-resampled image. This difference is relatively small, but if the resampled image turns out to be greater than the non-resampled image, what then is the importance of resampling? Is this a rare occurrence? Does this only happen to jpeg
files?
N/B: I worked with imagecreatefromjpeg
, imagecreatetruecolor
, imagecopyresampled
, and imageconvolution
(when resampling).