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 707239 - Gimp destroys image file when exporting as .tif with jpeg compression
Gimp destroys image file when exporting as .tif with jpeg compression
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: Plugins
2.8.6
Other All
: Normal normal
: 2.8
Assigned To: GIMP Bugs
GIMP Bugs
Depends on:
Blocks:
 
 
Reported: 2013-09-01 18:22 UTC by Thomas Hotz
Modified: 2014-05-07 16:53 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
example of the tiff file (331.51 KB, image/tiff)
2013-09-01 18:22 UTC, Thomas Hotz
  Details
proposed patch (5.43 KB, patch)
2014-05-05 16:28 UTC, Massimo
none Details | Review

Description Thomas Hotz 2013-09-01 18:22:57 UTC
Created attachment 253775 [details]
example of the tiff file

I'm reporting a bug from Ubuntu upstream: https://bugs.launchpad.net/ubuntu/+source/gimp/+bug/884145


To reproduce the bug follow these steps:

1. Start Gimp and open the example-before.tif with LZW compression attached below

2. Go to Image -> Mode -> Indexed, choose "Generate optimum palette -> Maximum number of colors", change the value from 256 to 16 and hit "Convert" button

3. Go to File -> Save, replace the file and change compression to jpeg

4. Now a message appears saying:

TIFF image Message
PhotometricInterpretation 3 not allowed for JPEG
TIFF image Message
Failed a scanline write on row 0
GIMP Message
Saving '/home/myname/example-after.tif' failed:
TIFF image plug-in could not save image

5. The file with the image on the disc now has a size of 8 bytes and cannot be opened or viewed anymore (see the example-after.tif attached)
Comment 1 André Klapper 2013-09-01 19:02:10 UTC
Which exact GIMP version and distribution version is this about?
Comment 2 Thomas Hotz 2013-09-02 10:41:27 UTC
In the bug it was the following version:

DistroRelease: Ubuntu 11.10
Package: gimp 2.6.11-2ubuntu4

I have tested and confirmed it with 
gimp 2.8.4 in Ubuntu 13.04 and gimp 2.8.6 in Ubuntu 13.10.
Comment 3 Michael Schumacher 2013-09-02 11:04:34 UTC
Searching for that error messages leads to e.g. http://www.asmail.be/msg0055325096.html

Change the image mode to RGB, and try again.
Comment 4 Thomas Hotz 2013-09-02 16:29:38 UTC
This works. 

It seems this is not possible with GIMP, because this function would need improvement or is this impossible to to that? Can you give me a more detailed explaination that will understand the reporter from the Ubuntu bug? I'm just asking because I simply don't know what to tell.

Thank you!
Comment 5 Michael Schumacher 2013-10-11 11:33:31 UTC
<nitpick mode>You can't reproduce this in 2.8.x, because you can't save an image to TIFF there</nickpick mode>

Exporting exhibits the same behavior, though. It may be possible to change the TIFF plug-in to check whether the current settings allow a file to be written before any writes to files happen.
Comment 6 Massimo 2014-05-05 16:28:43 UTC
Created attachment 275901 [details] [review]
proposed patch

The attached patch makes the JPEG radio button insensitive
when saving an indexed image, similarly to what happens
for Fax Group 3/4 compression only enabled for monochrome
images.

When called non-interactively it moves the file creation/truncation
after the error checking phase and it now returns an error
(also for incorrect attempt to compress a non bw with
G3/4 compression)

There are differences between gimp-2-8 and master in the tiff plug-in 
and since the patch introduces a translatable string, I don't know
whether it should be pushed to gimp-2-8 also. Perhaps without
the call to g_set_error_literal.
Comment 7 Michael Natterer 2014-05-05 16:46:16 UTC
An untranslated error message is still better than failing silently,
please go ahead.
Comment 8 Massimo 2014-05-07 16:53:07 UTC
This problem is fixed in gimp-2-8 and in master after the commit below,
but in master the same thing happens exporting an image with 16 bit
and choosing to compress with JPEG, I don't know whether to export
the 8 bits compressed as JPEG or to disable JPEG compression for
high depth images.

commit d053a751503373f976a26cfd7ff6bf8830228180
Author: Massimo Valentini <mvalentini@src.gnome.org>
Date:   Wed May 7 18:42:44 2014 +0200

    Bug 707239 - Gimp destroys image file when exporting...
    
    as .tif with jpeg compression
    
    make unsensitive the JPEG radio button when the image
    is indexed, similarly to Fax Group 3/4 compression
    enabled only for monochrome images
    
    move the file creation/truncation after checking for
    invalid requests and return a GError in case of error
    
    (cherry picked from commit 7e80e2e3bc77f17dac3fc0f712970a34215a6814)
    
    Conflicts:
        plug-ins/common/file-tiff-save.c