OK...  Since the bug tracker seems to have lost the bug report that I
wrote last week and I don't want to re-type it until I am sure that it
will not be lost again, I will post a description of the problem

Almost all File->Save plug-ins that are designed for single-layer file
formats (i.e. almost everything but .XCF) will save the current layer
(drawable) and ignore any other information from the image.  In some
cases, you could loose some of your work because of that.  The
following things are ignored when the current layer is saved:
1) canvas size
2) layer offset
3) layer mask (or layer itself, if a mask or a channel is selected!)
4) layer opacity

This bug exists in all versions of the Gimp, from 0.99.x to 1.1.27.
The first part of the problem (canvas size) was reported in #23610
(http://bugs.gnome.org/db/23/23610.html) but this bug is assigned to
"gimp-1.0", that's why I wanted to submit a more detailled report for
the current Gimp.

Most of the time, the bug (or design problem) will not be visible
because the "Export" feature will hide it: if the source image
contains several layers, flattening it will make the resulting
drawable equal to the visible image.  The "Export" feature will also
be triggered for a single-layer image with alpha if the output format
does not support transparency.  But in all other cases (e.g saving as
GIF, TIFF or PNG, or saving an image without alpha as JPEG), then some
information will be lost.


1) Ignoring the canvas size means that the saved file may contain some
   areas that should not be part of the visible image.  This is the
   problem reported in bug #23610 for gimp-1.0.4.

2) Ignoring the layer offset has the same effects as ignoring the
   canvas size: some parts of the layer may be outside of the canvas
   and should not be saved.

   Try this: load a file, then change the canvas size or move the
   layer with the move tool.  Save as GIF or JPEG and load the
   resulting file.  You will still see the original layer.  If you
   save as PNG and re-load, the layer offset will be saved but the
   layer will not be clipped to the canvas size (the result is

3) Ignoring the layer mask (or ignoring the layer data if the mask or
   a selection channel is selected) is the most dangerous part of this
   bug: you could loose some data if you do not see what went wrong
   and you do not have a copy of your source image in .XCF format.

   Try this: create or open an image, then add a layer mask and draw
   something in it.  Then save the image using a format that supports
   transparency (so that "Export" is not triggered) such as PNG, GIF
   or TIFF.  Depending on what was selected when you saved, the file
   will only contain the layer data without the mask, or only the mask
   (or selection channel) but not the image.  Oops!  You have lost
   half of your work...

4) Ignoring the layer opacity is a lesser problem.  But if you open a
   PNG image with transparency and move the opacity slider in order to
   make it more transparent, you could expect that the result would be
   correctly saved in a new PNG file, but it is not.  The result will
   be identical to the original image because the layer opacity was
   ignored.  Playing with transparency could become more frequent when
   more web browsers support PNG with alpha (correctly).

All these effects are related to the same design problem: most of the
File->Save plug-ins see only the current drawable and ignore the other
parameters of the image.  This is even worse when you correlate this
with bug #25272 (http://bugs.gnome.org/db/25/25272.html): the .xvpics
thumbnails are generated from the visible image, not from what gets
saved in the file.  So you may save your image and think that
everything went well when you see the thumbnails, but the contents of
the file are actually different.

What is the best way to fix these problems?  I don't know.  Some
changes could be done in the main app, and some others in the
plug-ins.  For example, the PNG plug-in is the only one (AFAIK) that
saves the layer offset because the file format supports this feature
(but it should also consider the canvas size).  The other plug-ins
could clip the layer to the canvas, but then the "Export" feature
should also be triggered for non-transparent file formats if some
areas are transparent because they are within the canvas but outside
the layer boundaries.

The most dangerous error is described in (3) and also as an example in
bug #25272: you could loose some of your work if a layer mask or a
channel mask is saved when you thought that the current layer would be
saved.  I don't know how to prevent that...  Maybe there could be a
warning if you attempt to save anything that is not the current layer
(but then we should also add an option in the gimprc to disable the
warning, and we are in feature freeze...).  At least, it would be nice
to have a warning if a channel mask is going to be saved (i.e. a
channel is active and you selected a file format other than XCF) and
the corresponding tab of the L&C&P dialog is not open, which indicates
that the user is probably about to make a mistake.

I think that the solution should be discussed here before attempting
to implement it, because it will affect most file plug-ins and it
should be designed carefully.  So, who starts with the suggestions?  :-)


Reply via email to