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 673729 - tiff plug in not working 2.8.0-RC1 windows install
tiff plug in not working 2.8.0-RC1 windows install
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: Plugins
2.8.0-RC1
Other Windows
: Normal critical
: 2.8
Assigned To: GIMP Bugs
GIMP Bugs
: 672469 673798 674190 674196 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2012-04-08 13:46 UTC by Terry Pinfold
Modified: 2013-12-08 13:36 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
TIFF load/save with libtiff-5.dll (3.03 KB, patch)
2012-05-01 17:22 UTC, Hartmut Kuhse
none Details | Review
load/save unicode named tiff with libtiff-5 (3.97 KB, patch)
2012-05-24 17:57 UTC, Hartmut Kuhse
none Details | Review
proposed patch (5.36 KB, patch)
2012-05-30 16:27 UTC, Massimo
none Details | Review

Description Terry Pinfold 2012-04-08 13:46:06 UTC
I can not open or save tiff files as the plugin will not write or read the files.These same files work fine on GIMP 2.7.5 and 2.6.12.
Comment 1 Hartmut Kuhse 2012-04-13 15:11:23 UTC
I think, it's a matter of libtiff.
I got the same problem, but the code in 2.7.5 and 2.8.0 RC1 didn't change.
I tried the older libtiff-3(.dll) and renamed it to libtiff-5(.dll).
the error is gone. Maybe you also have a mixture of libtiff libraries?
Comment 2 André Klapper 2012-04-16 11:27:41 UTC
*** Bug 674190 has been marked as a duplicate of this bug. ***
Comment 3 Michael Schumacher 2012-04-16 17:09:16 UTC
*** Bug 673798 has been marked as a duplicate of this bug. ***
Comment 4 Adam 2012-04-24 16:59:53 UTC
I also have this bug.
Comment 5 Adam 2012-04-25 10:33:37 UTC
(In reply to comment #1)
> I think, it's a matter of libtiff.
> I got the same problem, but the code in 2.7.5 and 2.8.0 RC1 didn't change.
> I tried the older libtiff-3(.dll) and renamed it to libtiff-5(.dll).
> the error is gone. Maybe you also have a mixture of libtiff libraries?

I can also confirm that this method works!
Comment 6 Hartmut Kuhse 2012-05-01 17:22:45 UTC
Created attachment 213224 [details] [review]
TIFF load/save with libtiff-5.dll
Comment 7 Hartmut Kuhse 2012-05-01 17:27:26 UTC
There seems to be a problem opening/saving files in libtiff-5 by file descriptor, at least in win32.
With the patch attached, TIFF-files are opened/saved with libtiff-5.dll
Comment 8 Michael Schumacher 2012-05-18 19:30:24 UTC
Does that work for files and directories with special characters - äöüß, chinese, japanese, ... - too?
Comment 9 Jernej Simončič 2012-05-18 19:51:46 UTC
Will this work when the path contains non-ASCII characters - specifically, try naming a file ★.tif (copy-and-paste the character; I chose this one because it almost certainly isn't in your ANSI codepage) and opening it.
Comment 10 Massimo 2012-05-19 09:55:22 UTC
I think this was an incompatible change in libtiff, see:

http://bugzilla.maptools.org/show_bug.cgi?id=1941

To be able to im/export tiff files on Windows I had to
configure and build tiff-4.0.1 with ac_cv_header_windows_h=no
                       
../tiff*/configure --host=x86_64-w64-mingw32 ... ac_cv_header_windows_h=no

this forces the usage of tif_unix.c instead of tif_win32.c and probably
produces a libtiff incompatible with the rest of the world.
      
But TIFFFdOpen in tif_win32.c does not expect a libc file descriptor, but
a win32 HANDLE converted to int.
        
One solution could be to get the handle from the file descriptor with _get_osfhandle, but since a HANDLE is a pointer I fear that on 64 bits, 
it is truncated in the call to TIFFFdOpen
          
Another solution would be (#ifdef G_OS_WIN32) to use TIFFFOpenW in the 
plug-ins after converting the filename with g_utf8_to_utf16.
Comment 11 Hartmut Kuhse 2012-05-20 14:00:13 UTC
No, the patch does not work for filenames wuth non-ascii-characters.
Comment 12 Jernej Simončič 2012-05-20 21:31:34 UTC
*** Bug 672469 has been marked as a duplicate of this bug. ***
Comment 13 Hartmut Kuhse 2012-05-24 17:56:03 UTC
I made a new patch.
With this one, gimp loads/saves also unicode tiff files (also the ★.tif) with libtiff-5.
tested on Win 7 64Bit and Win XP 32Bit
Comment 14 Hartmut Kuhse 2012-05-24 17:57:23 UTC
Created attachment 214887 [details] [review]
load/save unicode named tiff with libtiff-5
Comment 15 Michael Schumacher 2012-05-24 19:25:17 UTC
Isn't it possible to do this without that much Windows-specific code?
Comment 16 Hartmut Kuhse 2012-05-24 19:46:13 UTC
Don't think so, but I'm no very expert. Libtiff-5 has a special win_32 code, which is used, when compiled in a windows environment. I didn't want to compile libtiff so I had to deal with in the plug-in.
In windows environment, libtiff uses windows file handle to open with TIFFFdOpen, and windows file handles are completely different to posix file descriptors, which is created by g_open. So I had to get a file handle. Windows uses wide-character unicode, glib uses multibyte unicode, so the filename has to be converted. I'm no expert, I just want to help - sorry.
Comment 17 Michael Natterer 2012-05-25 07:17:07 UTC
This sounds entirely reasonable, but I'd like a review from our windows
experts before we push this.
Comment 18 Michael Schumacher 2012-05-28 10:49:32 UTC
*** Bug 674196 has been marked as a duplicate of this bug. ***
Comment 19 Massimo 2012-05-30 16:27:56 UTC
Created attachment 215262 [details] [review]
proposed patch

I waited to attach a patch here because I wanted to test it.

The problem is that in tif_win32.c all possible code paths
(TIFFOpen, TIFFOpenW, TIFFFdOpen) truncate a HANDLE to an int
and then reassign the int to a HANDLE, and even though this could
be problematic on 64 bit, it doesn't seem to be in practice.

Obviously the correct solution would be to fix libtiff.

I reduced the Windows-specific code using glib's string conversion
utilities and TIFFOpenW, that is available from both tif_win32.c and
tif_unix.c.

I tested the patch, with filenames containing non ASCII-characters,
on Windows.

One thing I noticed that is still wrong is that if you
try to export as a tiff with JPEG compression, a RGBA image
(with alpha channels), it fails, but creates a file (8 bytes long)
that is saved in the history and then trying to reload it, 
clearly fails.

Probably, when exporting an image RGBA, JPEG compression should
be disabled as it is for Fax CCITT Gr. 3 and 4.
Comment 20 Massimo 2012-06-09 13:51:42 UTC
Fixed in master and gimp-2-8.

Many thanks to Hartmut for finding out the bug and for
the patches contributed.

commit 0ba99a05ff162a6894686035398b0a82a348a5d7
Author: Massimo Valentini <mvalentini@src.gnome.org>
Date:   Sat Jun 9 15:36:35 2012 +0200

    Bug 673729: tiff plug in not working 2.8.0-RC1 windows install

    implement win32 filename Unicode management in the plug-ins
    to work-around a problem in libtiff TIFFFdOpen.

    Based on a patch from Hartmut Kuhse.