Currently, image.inc when resizing a 8-bit PNG generates a 24-bit PNG.
Though 24-bit PNG display fine in all browsers when there is no alpha information, they use more bandwidth than 8-bit. This patch makes image.inc generate 8-bit PNG when given 8-bit PNG on resizing operations. The resizing is still done using 24-bit temporary image, indexing to 8-bit and polishing with imageColorMatch :
[IN:Original 8-bit image] => [Scaled 24-bit image] => [8-bit image] => [imageColorMatch] => [OUT:8 bit-image]
Included is a imageColorMatch replacement (translated from the C code) for those PHP installations that don't provide it. It's pretty slow, but as resizing is typically a 1-shot deal, I see no real problem there.
The conversion will _not_ work properly with transparent PNGs. Automating this would not give great results anyway because of the alpha thresholding.
This patch is against image.inc v1.12; v1.12+this_patch should work on at least Drupal 4.6 and 4.7
| Comment | File | Size | Author |
|---|---|---|---|
| image.inc.8bitpng.patch | 3.07 KB | ptaff |
Comments
Comment #1
Tobias Maier commentedwe dont accept new features against any already released version, only against the current developer version which is called CVS/HEAD
So please make a patch if necessary against CVS/HEAD - the upcomming drupal 4.7
Comment #2
ptaff commentedThe patch is already against the CVS' latest image.inc (v1.12) (which works with 4.6 and 4.7). Sorry, a simple case of mis-categorization.
Comment #3
robin monks commentedSwitched to bug report since this is really something we should do right, but don't.
Tested locally and all looked/worked well. I'd still like someone with intimate graphics+php knowledge to take a second look at this, but it should be good to go. Tested on WAMP/PHP5/MySQL5/Drupal CVS.
Robin
I ♥ Bugz
Comment #4
dries commentedNot sure this is a real bug, or whether it needs fixing ...
Comment #5
Stefan Nagtegaal commentedI'll investigate this...
Comment #6
drummFix up the code style.
- Two space indents only.
- Properly spaced and formatted /* */ comments above functions for auto-generated documentation
- Only // comments inline.
Comment #7
ricabrantes commentedThis is active??
Comment #8
robin monks commentedOh yeah.
Robin
I ♥ Bugz
Comment #9
miopa commentedI would say it's a bug. My png thumbnails are often twice the size of the original image. Is it possible to port this solution to verzion 6?