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

1

9

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.

Iolaiolande answered 19/9, 2014 at 1:9 Comment(0)
E
8

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 :)

Entree answered 19/9, 2014 at 1:21 Comment(2)
thank you very much, It did. Do you know the answer of my second question?Iolaiolande
I haven't done that yet try checking out this post. #21525625Entree

© 2022 - 2024 — McMap. All rights reserved.