GNOME Bugzilla – Bug 129472
Adds option to strip color data from transparent pixels
Last modified: 2004-12-22 21:47:04 UTC
As Raphael has pointed in a recent thread in Gimp-devel, uniformizing pixels hid by a 0 value of alpha can enhance the compression of PNG files, and seens to be even recommended. Making it optional preserves the user control over his own image. I am adding a patch that adds the option to reset or not the color values for transparent pixels when saving a RGBA PNG image. The patch sets the transparent pixels to zero, or to the current background color, if the user chooses "Save Background Color".
Created attachment 22484 [details] [review] Patch to implement the enhancement.
Hi, I think this could be committed before 2.0 - it's a small change, which is a useful optimisation. Setting the 1.3.x milestone. I don't think I will have time to commit this - unless there are objections, could someone else do the necessary? Thanks, Dave.
The problem here is that the patch changes the PDB API. This would break a lot of scripts that call file-save-png. I am not sure if it's worth it. I also have some minor issues with the code change itself, namely variable names and the use of a binary shift operation where a simple multiplication would be more readable. The compiler will generate the same binary code anyway.
As for the PDB API: I took care of having the filter accept either the previous 12 parameters or the 13 parameters after the patch. AT least py-slice (python rewrite of perl-o-tine) worked fine with the patch applied. Maybe more testing should be done. I could only think of this pluguin that uses png save. IMHO, 15% smaller PNGs for web-developers is something that could make a difference right for 2.0. Otherwise, here goes another idea: make the "zero out transparent pixels to save" a global GIMP option, and have then zeroed in the flatten image function called when a multi-layer image is exported to be saved. That would not hurt the PDB, and would work for all file formats, but I do not see it coming in for earlier than 2.1 - Meanwhile, the GIMP could have this one more utility to web artists. Cansomeone check if any filters are really broken? As for the variable names, and the shift, I will take care of them.
Didn't knew that omitting parameters works for py-gimp also. It doesn't work for script-fu though. However, I don't have a strong opinion on this. Perhaps someone else's opinion can help to decide this point.
I'd rather not break the PDB api. How about just registering a second procedure for this?
I'd like to see this applied, if it doesn't break stuff. I thought the trick of omitting pdb parameters was pretty widespread... if it's not we should have two calls for the PDB registered, as is done in the edge detect plug-in, for example. Cheers, Dave.
Created attachment 22727 [details] [review] Updated patch which installs a new procedure
There might be better ways to do this, but anyway - here's an updated patch with a fair amount of copy & pasting. Two sets of arguments, two procedure calls. Can someone have a look and see if this is OK to commit? Cheers, Dave.
2004-01-05 Sven Neumann <sven@gimp.org> * plug-ins/common/png.c: applied a modified patch provided by Joao S. O. Bueno and Dave Neary. The user can now specify whether color values for transparent pixels should be saved or nullified (bug #129472).