writing multi-image tiff

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
User avatar
GreenKoopa
Posts: 457
Joined: 2010-11-04T17:24:08-07:00
Authentication code: 8675308

writing multi-image tiff

Post by GreenKoopa »

Way back at version 6.8.3-0 I could create a tiff containing multiple images and open it in GIMP as layers (or separate images). Using version 6.8.4-8 and up there are several changes. The tiff is significantly fewer bytes. GIMP lists all the images and can open any one, but can't open all at once. Any idea what changed?

For example:
convert -size 500x500 -depth 8 xc:white xc:red gradient:white-black out.tiff
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: writing multi-image tiff

Post by magick »

Add -type TrueColor to your command line:
  • convert -size 500x500 -depth 8 xc:white xc:red gradient:white-black -type truecolor out.tiff
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: writing multi-image tiff

Post by snibgo »

It fails for me: IM v6.8.6-5, Gimp 2.8.2, on Windows 7.

In Gimp, I can open all the images as separate images. But when I ask to open them as slayers, I get only 2 layers.

When I create my tiff with an extra layer, Gimp can still open only 2.

It worked fine in 6.8.4-0.
snibgo's IM pages: im.snibgo.com
User avatar
GreenKoopa
Posts: 457
Joined: 2010-11-04T17:24:08-07:00
Authentication code: 8675308

Re: writing multi-image tiff

Post by GreenKoopa »

I am on Windows 7, also using the latest GIMP. Are you seeing the tiff file size change?

Further testing:
I get the same undesirable result using 6.8.4-8, 6.8.5-6, and 6.8.6-3.
Opening as images works. The problem is only with opening as layers.
The more images I add to the file, the more that appear and the more that go missing.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: writing multi-image tiff

Post by snibgo »

When the images are in colour, with +compress, I see almost no difference in file size. Version 6.8.6-5 and 6.8.3-0:

"%IMG6865%convert -size 500x500 -depth 8 xc:pink xc:red gradient:white-blue xc:green +compress out.tiff

"%IMG683%convert" -size 500x500 -depth 8 xc:pink xc:red gradient:white-blue xc:green +compress out3.tiff

Sizes are 3,004,367 and 3,004,368 bytes.

Monochrome images are smaller in the newer IM. Compressed sizes are also smaller. I doubt that this is relevant.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: writing multi-image tiff

Post by fmw42 »

When I run this on my Mac with IM 6.8.6.5 Q16

convert -size 500x500 xc:white xc:red gradient:"white-black" -depth 8 out.tiff

IM verbose info show 3 layers. But when I try to open it in my ancient PS CS it only shows the first layer (solid white).
User avatar
GreenKoopa
Posts: 457
Joined: 2010-11-04T17:24:08-07:00
Authentication code: 8675308

Re: writing multi-image tiff

Post by GreenKoopa »

snibgo wrote: When the images are in colour, with +compress, I see almost no difference in file size. ... Monochrome images are smaller in the newer IM. Compressed sizes are also smaller. I doubt that this is relevant.
Good observation!

When all of the images are TrueColor (tiff:photometric: RGB), it works properly.
When all of the images are Grayscale (tiff:photometric: min-is-black), it works properly.
Grayscale was saved as TrueColor in older versions.
So -type TrueColor is a work around!
User avatar
GreenKoopa
Posts: 457
Joined: 2010-11-04T17:24:08-07:00
Authentication code: 8675308

Re: writing multi-image tiff

Post by GreenKoopa »

At first the unexpected behavior made no sense. All of the images were in the tiff file. IM could see them. GIMP could see them. GIMP could even open them, as long as it was one at a time. So why not all at once? And why does a seemingly random selection of layers get opened while others are silently skipped?

Mixed -type/color modes makes perfect sense. Treated as separate images, there is no need to all match. But as layers, the entire image must be in a single mode. Any layer not matching the color mode of the first is silently skipped by GIMP.

The only time I use tiff is when I want layers in GIMP.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: writing multi-image tiff

Post by snibgo »

Ah, yes, I hadn't taken my tests quite far enough. When the images are all colour (more specifically, the same type), Gimp can open them all as layers.

That's a great tip to know. I could never figure out why I couldn't make a tiff out of both a photo and a greyscale mask and open them together as layers in Gimp. Now I know how. Yippee!

I think we can agree this isn't an IM bug? (I'd say it exposes a problem in Gimp: claiming to open the images as layers, but silently ignoring some.)
snibgo's IM pages: im.snibgo.com
User avatar
GreenKoopa
Posts: 457
Joined: 2010-11-04T17:24:08-07:00
Authentication code: 8675308

Re: writing multi-image tiff

Post by GreenKoopa »

snibgo wrote: That's a great tip to know. I could never figure out why I couldn't make a tiff out of both a photo and a greyscale mask and open them together as layers in Gimp. Now I know how. Yippee!
I think this used to work for me. This is a change.
snibgo wrote: I think we can agree this isn't an IM bug?
There is nothing in the change log about tiff, so maybe this change was unintentional. In either case, this would be my criteria:
Does IM's output conform to the tiff standard (if there even is a standard)
Does PS write tiff files like IM? GIMP and others will try to support whatever PS outputs.
Will PS read IM's output? If not, it's not standard enough.

If this is a standard-compliant tiff, I don't mind specifying -type TrueColor -depth 8 for use with GIMP. Is there a way for a user to specify -type least_common_denominator? A user only wants TrueColor when at least one image in the sequence requires it. Personally, I don't use tiff often enough to care. I just want a way to save a file with layers for use with GIMP and PS.

Note that tiff:rows-per-strip also changed.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: writing multi-image tiff

Post by fmw42 »

My attempts to add -type truecolor to my command above, did not help to import the layers into Photoshop (at least not my very old PS CS).
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: writing multi-image tiff

Post by fmw42 »

When I run this in IM 6.8.6.5 Q16 Mac OSX

convert -size 500x500 xc:white xc:red gradient:"white-black" -depth 8 -type truecolor out.psd

and open in PS CS it only shows two layers -- the white and the gradient, but not the red

when I run this

convert -size 500x500 xc:white xc:red gradient:"white-black" -depth 8 -type truecolor out.tiff

and open in PS CS it only shows one layer -- the white
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: writing multi-image tiff

Post by snibgo »

I used to have problems doing this with Gimp, probably building the layered tiff from different tiff files (with different types).
GreenKoopa wrote:In either case, this would be my criteria: ...
Yes, good points about the standards and "-type least_common_denominator".
snibgo's IM pages: im.snibgo.com
Post Reply