PHP : why does imagepng() function increase the size when saving the image?

PHP : why does imagepng() function increase the size when saving the image?

There are many ways to store an image in a PNG file. The method used must differ between your original and the image saved by PHP. See:

https://www.w3.org/TR/2003/REC-PNG-20031110

If you look in the manual where imagepng() is documented you can see that PHP also has some options. For instance the $quality parameter. This is one way of making the file smaller.

With imagetruecolortopalette() you can try to reduce the color depth of the image. This can also make the output file smaller.

Not all methods to make images smaller, that are supported by the PNG file format, are supported by PHP.

PHP : why does imagepng() function increase the size when saving the image?

Leave a Reply

Your email address will not be published.