After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 78648 - Adding alpha layer to indexed png with 256 colors doesn't work
Adding alpha layer to indexed png with 256 colors doesn't work
Status: VERIFIED DUPLICATE of bug 55700
Product: GIMP
Classification: Other
Component: Plugins
1.x
Other Linux
: Normal normal
: ---
Assigned To: GIMP Bugs
Daniel Egger
Depends on:
Blocks:
 
 
Reported: 2002-04-14 10:28 UTC by Dave Neary
Modified: 2009-08-15 18:40 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Dave Neary 2002-04-14 10:28:15 UTC
Sorry for the vague description.

Fron a guy on the comp.apps.graphic.gimp newsgroup, confirmed here. 

> Here's the image I was working on, in its original no-alpha form, and
> the final version after successfully adding transparency:
> 
> http://xultekh.net.nz/gimp/next.png
> http://xultekh.net.nz/gimp/next2.png
> 
> The exact sequence of operations I used:
> 
> Open next.png
> Right-click menu: Layers -> Add alpha channel
> Select magic wand from toolbox
> Click in the blue border area to select it
> Ctrl-K (border is now transparent)
> Save
>
> At this point, transparency is still visible in the displayed image but
> it isn't saved in the file (File -> Revert to see this). It works if you
> add Image -> Mode -> RGB anywhere in the sequence, and Image -> Mode ->
> Indexed (optimal palette, 255 colours) immediately before saving it.


This is exactly the behaviour I've seen. So when there's transparency on a
drawable, to get it saved in an indexed image, you need to convert to rgb
and convert it back which seems silly & pointless to me. I think this is a bug.

Dave.
Comment 1 Branko Collin 2002-04-16 22:22:17 UTC
There were two others (as far as I can tell) that reported the same or
a similar problem earlier, but a lot of other users on the news group
cannot confirm the bug.

Confirmations: 

http://groups.google.com/groups?selm=3B29C10F.C86C2C79%40unine.ch

http://groups.google.com/groups?selm=4g598uccc9iiuk5d3rn6uj24hlsovbum52%404ax.com

Comment 2 Michael Natterer 2002-04-25 17:27:06 UTC
Seems I have tracked down the bug to
plug-ins/common/png.c:respin_cmap() which behaves differently
with a palette of 256 colors than it behaves with < 256 colors.

Your example image http://xultekh.net.nz/gimp/next.png has a
palette of 256 colors, but it uses only 5 of them.

When converting the image to RGB and back, GIMP optimizes the
useless colors away, creating free space in the palette
respin_cmap() uses to do things i don't understand but seem
to be needed for indexed-alpha PNGs (???)

I'd like to add Nick to the CC list because we need some more
info from Mr. PNG himself here :-)

Unfortunately, bugzilla is not very helpful in finding
people's account names...
Comment 3 Raphaël Quinet 2002-04-26 07:30:33 UTC
I added Nick to the CC list.  Note to Mitch: you could have seen his
e-mail address by reading the message that I posted on the gimp-dev
list on the 10th of April, titled "Suggestion: add Bugzilla contact
info in PLUGIN_MAINTAINERS".  This reminds me that I still have to
post a follow-up to that message and update the PLUGIN_MAINTAINERS
file...
Comment 4 Nick Lamb 2002-04-26 13:19:27 UTC
respin_cmap() converts GIMP's world view (indexed color and
transparency are unrelated, and transparency is binary) to PNG's world
view (indices point to a color AND transparency, transparency is 8
bit) by inserting an additional entry into the colormap which is a
placeholder for transparent pixels, much like GIF.

PNG can do better than this(*) and maybe one day I will write support
for a live web-optimiser preview and 5x5x5x2 hypercuboid RGBA palettes
and all sorts of other lovely features, but GIMP makes this sort of
thing harder that it should, for now anyway, and I don't find time.

It's worth pointing out once again that no file formats map cleanly
onto the Gimp INDEXEDA mode, and IMHO it should die a quick death.

Obviously when a GIMP image has mode INDEXEDA, and has a 256 color
palette (which is strongly discouraged for transparent images) it's
impossible to re-arrange things without basically pasting the entire
image mode conversion software inside PNG. So right now the PNG
plug-in gives up and throws away the transparency.

Perhaps instead we should try to spot this before Export and tell the
Export engine to convert the image to RGBA if it has too many palette
entries to cope with normally. Is that acceptable (the result is a
somewhat larger file size but visually correct image) ? I can probably
write a patch to do this now that I've actually thought of it.

(*) Well, it can in everything except the world's most popular web
browser, IE for Windows, which can't do transparency. Sigh.
Comment 5 Raphaël Quinet 2002-04-26 20:12:25 UTC
> It's worth pointing out once again that no file formats map cleanly
> onto the Gimp INDEXEDA mode, and IMHO it should die a quick death.

Well, there are several file formats that map (almost) cleanly onto
the INDEXEDA mode.  GIF is the most obvious candidate, but some
internal masked bitmap formats used by several old games are also
very close to the INDEXEDA mode.

> Perhaps instead we should try to spot this before Export and tell
> the Export engine to convert the image to RGBA if it has too many
> palette entries to cope with normally. Is that acceptable (the
> result is a somewhat larger file size but visually correct image) ?

No, that would be annoying because the reason to use INDEXED mode
(with or withoug alpha) is usually to reduce the size of the file.
It would be much better IMHO to change gimp_export_image() so that it
can detect if the number of palette entries (+ 1 if there is an alpha
channel) is larger than 256.  If yes, then it should simply call
gimp_image_convert_rgb() followed by export_convert_indexed().  This
two-step conversion would ensure that the final image is still indexed
and that it has less than 256 palette entries.

We can add this test for all indexed file formats, or only for those
that cannot handle more than 256 colors.  In the latter case, we could
add a new constant GIMP_EXPORT_CAN_HANDLE_LARGE_INDEXED to control if
the size of the palette should be checked or not.  I do not know if
any file format would support that for the moment, but it would be
nice to allow that.

I could work on a patch that does that (I already had fun with the
Export dialog while dealing with bug #51114 so I have some experience
with that code).  But I would like to know if you think that it would
be an appropriate solution.  Opinions?
Comment 6 Dave Neary 2003-01-08 13:37:02 UTC
Isn't this a duplicate of bug #55700?

In which case, I checked in a fix for this in both branches in
October/November. 

Marking as a duplicate - if it isn't could somepne please explain why?

Cheers,
Dave.

*** This bug has been marked as a duplicate of 55700 ***
Comment 7 Raphaël Quinet 2003-06-20 16:47:06 UTC
The fix for bug #55700 is part of the stable release 1.2.4.  Closing
this bug.