Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the default value of `quality` parameter in `imagepng` function (`PHP`)?

I have used imagepng function in PHP to resize pictures. In the current code, I have not specified the quality parameter.

 imagepng($im_dest, $destfile);

But now I want to use it and increase or decrease the quality based on user's demand. To do that I need to know what is the default value of quality parameter in this function but unfortunately, I could not find that in the php.net website.

description of imagepng function in the official website of php

Do you know what is the default value? Does the quality parameter greatly affects the output size and quality?

One more question: Somewhere else, I resize the uploaded images (to their original sizes) to ensure there is not any malicious script attached to it. Is it a good practice or it is unnecessary?

Thank you very much for being helpful.

like image 462
Ormoz Avatar asked Sep 19 '14 01:09

Ormoz


1 Answers

While I was reading some of the user contribute notes I found this one and saying that the default quality is set to 6.

from mhorne69 at gmail dot com

from php source (gd.h):

2.0.12: Compression level: 0-9 or -1, where 0 is NO COMPRESSION at all, 1 is FASTEST but produces larger files, 9 provides the best compression (smallest files) but takes a long time to compress, and -1 selects the default compiled into the zlib library. Conclusion: Based on the Zlib manual (http://www.zlib.net/manual.html) the default compression level is set to 6.

I hope that answers your question :)

like image 132
loki9 Avatar answered Oct 14 '22 07:10

loki9