PNG filter support
| From: | Keith Ito | Date: | Wed, 17 Jan 2007 00:09:47 +0000 |
| Subject: | PNG filter support | ||
| Groups: | php.gd.devel | ||
| Request: | Send a blank email to php-gd-devel+get-41@lists.php.net to get a copy of this message | ||
Hi,
My apologies in advance if this is the wrong list for feature requests.
Anyhow, I'd like to request that GD expose an API allowing the caller
to control the filter used when writing PNG images. There is a
comment in gd_png.c saying this would be done in gdImagePngCtxEx(),
but I suppose it was overlooked when that function was added.
For truecolor images, the PNG filter that will deliver the best
compression depends largely on the image. For many photographs, the
default heuristic will deliver the best performance, but for other
types of images such as artwork without so many colors,
PNG_FILTER_NONE can be better. For example, the image of Tux linked
below is 16646 bytes when compressed with default settings and 15649
bytes with PNG_FILTER_NONE, a savings of about 6%. Note that in both
cases, the compression is lossless.
http://www.convoluted.net/pngfilter/tux_before.png
http://www.convoluted.net/pngfilter/tux_after.png
The choice of filter can make a particularly large difference with
transparent truecolor images. For example, this image is 83767 bytes
when saved using the default filter, and only 47124 bytes when using
the PNG_FILTER_NONE, a savings of 44%.
http://www.convoluted.net/pngfilter/transparent_before.png
http://www.convoluted.net/pngfilter/transparent_after.png
As a result, I think it would be very useful for a caller who knew
something about the images she would be processing to be able to set
the filter type according to her best judgement.
I have attached a patch that adds new functions to allow the caller to
specify the PNG filter in calls to gdImagePngXXX. Please let me know
if this is something you would consider accepting.
Thanks!
Keith