Converting transparent GIFs to TIFF

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
martinw17
Posts: 39
Joined: 2006-09-07T02:10:27-07:00
Location: Brighton, UK

Converting transparent GIFs to TIFF

Post by martinw17 »

I am having difficulting converting GIFs that have a transparent background into TIFFs that will open in Windows Picture and Fax Viewer (or display as thumbnails in Windows Explorer).

For example, using the following GIF file: http://www.bright-interactive.com/downloads/test.gif

with ImageMagick 6.2.9-3 on Windows XP as follows:
convert -compress LZW test.gif test.tif

I get this file: http://www.bright-interactive.com/downloads/test.tif

which isn't recognised by Windows (Picture and Fax Viewer or as a thumbnail). It opens ok in Photoshop.

When I convert it using Image Magick 6.2.3 on Linux, it seems to work fine. I have also had reports that it works on some Windows PCs using ImageMagick 6.2.9-3 (although we have tried on 3 PCs without success).

Given this, can this be a problem with TIFF libraries that IM depends on? (Does it delegate to libs when running on Windows or is everything it needs built into the executable?)

Any help or ideas will be very welcome!
Martin
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

Tiff is always a problem format, and rearly implemented fully by specific programs.
For details see IM Examples, Common File Formats,
http://www.cit.gu.edu.au/~anthony/graph ... s/#summary
and some raw notes for tiff conversions
http://www.cit.gu.edu.au/~anthony/graph ... mats/#misc

More than likely you will need to find out what sort of tiff the program wants and try to produce that type of TIFF.. Yuck!

Anyone else have info please share.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
martinw17
Posts: 39
Joined: 2006-09-07T02:10:27-07:00
Location: Brighton, UK

Post by martinw17 »

Thanks Anthony.

I have noticed that the TIFF that works has the following Photometric Interpretation: RGB color
whereas the one that doesn't has:
Photometric Interpretation: palette color (RGB from colormap)

Is this relevant? Is it likely that Windows viewer can only deal with certain values for Photometric Interpretation?

If so, do you know if it is possible to change the Photometric Interpretation ImageMagick is using?

Thanks,
Martin
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

I don't know about Windows specifically. However I beleve if you use " -depth 8 -type TrueColor " before saving to TIFF, may do the trick. I can't be certain it work, but it sound right.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
martinw17
Posts: 39
Joined: 2006-09-07T02:10:27-07:00
Location: Brighton, UK

Post by martinw17 »

Thanks very much Anthony! The -type TrueColor option does the trick.

I can now confirm the following:
- Windows Picture and Fax Viewer, and Windows Explorer (when displaying thumbnails) can only display TIFFs that have certain Photometric Interpretation values. (I have seen it work only if the Photometric Interpretation is RGB color, however there may be others for which it works too).
- The following options for ImageMagick's convert result in a TIFF that can be displayed by Windows PFV:
convert -compress LZW -type TrueColor test.gif test.tif

Thanks again for your input Anthony.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

Just one final point... Read the image BEFORE modifying it.

Code: Select all

convert  test.gif    -compress LZW -type TrueColor    test.tif 
In this can -compress is a output setting, so it does not matter, BUT -type is an operator that works on images in memory.

Your version ONLY works because you did not read in an image before attempting to mody it, so it saved the operations until you did read an image.

This is a legacy mode, designed for backward compatibility with IM version 5, and may be discontinued, or produce warnings in the distant future.

See IM Examples, Basics
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
martinw17
Posts: 39
Joined: 2006-09-07T02:10:27-07:00
Location: Brighton, UK

Post by martinw17 »

Here's some strange behaviour: if I convert the GIF as follows:
convert test.gif -compress LZW -type TrueColor -depth 8 test.tif

then the image looks like it has a transparent background when I open it in GIMP, but a white background if I open it in Photoshop.

If I then resize the image as well, e.g.
convert test.gif -compress LZW -type TrueColor -depth 8 -resize 200 test.tif

then the resulting image appear to have a black background in Photoshop!

Any ideas what is going on? Ideally I would like my TIFF image to have a transparent background when opened in Photoshop (i.e. not white or black).
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

It looks as if the TIFF format does not have an alpha channel. I don't know how to fix that however.

Basically the background color would be the original "transparency color" stored in the GIF format. See IM Examples GIF Transparency Color
http://www.cit.gu.edu.au/~anthony/graph ... #gif_trans

When your resized the image the transparency color of the image became the mathematical transparent color of 'none' EG fully-transparent black!.

If this is a problem -flatten the image onto the backgroudn color of your choice before
resizing it to remove the transparency. See the last part of Flatten
http://www.cit.gu.edu.au/~anthony/graph ... s/#flatten
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply