GNOME Bugzilla – Bug 707239
Gimp destroys image file when exporting as .tif with jpeg compression
Last modified: 2014-05-07 16:53:07 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)
Which exact GIMP version and distribution version is this about?
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.
Searching for that error messages leads to e.g. http://www.asmail.be/msg0055325096.html Change the image mode to RGB, and try again.
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!
<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.
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.
An untranslated error message is still better than failing silently, please go ahead.
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