Doc #74364 [Opn->Ver]: imagepng misses default value for $quality param
| From: | requinix@php.net | Date: | Mon, 03 Apr 2017 07:52:59 +0000 |
| Subject: | Doc #74364 [Opn->Ver]: imagepng misses default value for $quality param | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-14571@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74364&edit=1
ID: 74364
Updated by: requinix@php.net
Reported by: maggus dot staab at googlemail dot com
Summary: imagepng misses default value for $quality param
-Status: Open
+Status: Verified
Type: Documentation Problem
-Package: Documentation problem
+Package: GD related
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
tldr: The default depends on zlib but is probably 6.
:375 is not quite the right place. That does define the arguments but is not where the defaults are
- see how everything uses 0? To see the default you have to check the code in the function itself
(:2747). However that just passes execution to _php_image_output_ctx (gd_ctx.c:82), which does
extract the arguments (:120) with quality=$quality. Then it sets q=quality if it had been passed to
the function (:129) or else it will remain with its initial value of -1 (:91). GD gets involved
later (:202) by calling *func_p, which was an argument passed to _php_image_output_ctx (from back in
gd.c) and, in the case of imagepng, is gdImagePngCtxEx.
At this point you hit up Google and find
https://libgd.github.io/manuals/2.2.2/files/gd_png-c.html
where gdImagePngCtxEx says the default compression is -1 too. Jump to "gdIamgePnEx" (lol)
and you get
> A compression level of -1 will use the default compression level at the time
> zlib was compiled on your system.
Back to Google one more time and we find
http://www.zlib.net/manual.html
> Compression levels.
> #define Z_DEFAULT_COMPRESSION (-1)
...
> Z_DEFAULT_COMPRESSION requests a default compromise between speed and compression
> (currently equivalent to level 6).
Previous Comments:
------------------------------------------------------------------------
[2017-04-03 07:15:34] maggus dot staab at googlemail dot com
Description:
------------
the docs mention the valid for $quality spans from 0-9 but it doesnt mention what the default value
is.
it defaults to 0 it seems (dont rely on my non-existent C-fu tho)
https://lxr.room11.org/xref/php-src%40master/ext/gd/gd.c#375
---
From manual page: http://www.php.net/function.imagepng
---
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=74364&edit=1