Can't flatten tif files???

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
baraka2000
Posts: 5
Joined: 2013-11-21T10:49:42-07:00
Authentication code: 6789

Can't flatten tif files???

Post by baraka2000 »

Hi,

I'm trying to do something very simple with IM. But no matter what command I try I can't seem to hack it. I'm very simply trying to flatten a layered tif/tiff file. This file is created in PS. I can't post this particular file because it's a celeb and I'd get in trouble, but suffice to say its just a layered tiff and I want to flatten it.

I've tried:
convert -flatten -background white in.tif out.tif
convert -flatten in.tif out.tif
convert in.tif -layers out.tif
convert in.tif -alpha off -layers flatten out_file.tif
convert in.tif -flatten
convert in.tif -flatten out.tif

I get these errors (which I've read doesn't mean anything and can be ignored...)

convert: Incompatible type for "RichTIFFIPTC"; tag ignored. `TIFFFetchNormalTag' @ warning/tiff.c/TIFFWarnings/837.
convert: Unknown field with tag 306 (0x132) encountered. `TIFFReadCustomDirectory' @ warning/tiff.c/TIFFWarnings/837.
convert: Incompatible type for "FileSource"; tag ignored. `TIFFFetchNormalTag' @ warning/tiff.c/TIFFWarnings/837.
convert: Incompatible type for "SceneType"; tag ignored. `TIFFFetchNormalTag' @ warning/tiff.c/TIFFWarnings/837.
convert: Incompatible type for "RichTIFFIPTC"; tag ignored. `TIFFFetchNormalTag' @ warning/tiff.c/TIFFWarnings/837.

I've read all the related threads, tried the above commands, no luck. Any help here would be helpful.
Thanks,
Kevin
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Can't flatten tif files???

Post by snibgo »

Code: Select all

convert in.tif -flatten out.tif
... should do it. But you have tried that. What happened instead of the expected result?

What version of IM on what platform?
snibgo's IM pages: im.snibgo.com
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Can't flatten tif files???

Post by Bonzo »

I can't post this particular file because it's a celeb and I'd get in trouble
If you created the tiff file or somebody in your organisation created it why not create another one that is not sensitive and post a link to that?
baraka2000
Posts: 5
Joined: 2013-11-21T10:49:42-07:00
Authentication code: 6789

Re: Can't flatten tif files???

Post by baraka2000 »

I've pasted over the sensitive stuff in this image. I did try with a different image and did get things to work. So my guess if the iptc errors are preventing IM from doing it's thing. But how to get around this?

Here's the file in question: https://www.hightail.com/download/OGhkZ ... WGNPd3NUQw

Version: ImageMagick 6.6.9-7
TIFF* TIFF rw+ Tagged Image File Format (LIBTIFF, Version 3.9.5)
TIFF64* TIFF --- Tagged Image File Format (64-bit) (LIBTIFF, Version 3.9.5)

And a few other questions, I was planning to just run this command on all tif files we receive (some layered, most not) but in the interest of saving processing time, is there a way to check for layers with IM, and if true then run the flatten command??

Lastly can I overwrite the input file with the flat version, eg no output file??

Thanks!
Kevin
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Can't flatten tif files???

Post by fmw42 »

This seems to work fine for me on IM 6.8.7.6 Q16 Mac OSX and LIBTIFF, Version 4.0.3

convert Shot_03_Single_034.tif -background black -flatten Shot_03_Single_034.png

It is either your version of IM or libtiff or both that may be too old. Can you upgrade

check your version of libtiff

tiffinfo
LIBTIFF, Version 4.0.3
...
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Can't flatten tif files???

Post by snibgo »

Here's the file in question: https://www.hightail.com/download/OGhkZ ... WGNPd3NUQw
That file contains only one image, with no transparency. What do you expect flatten to do? What do you want it to do?
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: Can't flatten tif files???

Post by fmw42 »

The tiff file opened in PS shows several layers. I suspect IM is flattening them already, since it probably does not know about grouped layers. In any case, my result from IM, which as snibgo says sees only one layer in the original when opened, looks exactly like what you see in PS with all layers on (or if you were to flatten or merge them all).
baraka2000
Posts: 5
Joined: 2013-11-21T10:49:42-07:00
Authentication code: 6789

Re: Can't flatten tif files???

Post by baraka2000 »

So I gave you my server IM version, I forgot I was in a ssh session when I checked...

But my testing has all been local on my Mac 10.8.5 with:

TIFF* TIFF rw+ Tagged Image File Format (LIBTIFF, Version 4.0.3)
TIFF64* TIFF rw- Tagged Image File Format (64-bit) (LIBTIFF, Version 4
ImageMagick 6.8.7-0 2013-11-11 Q16 http://www.imagemagick.org

I tried upgrading using Home Brew, and it seems to think this is the latest... Obviously it's not.

And yes I can convert to a png or jpg and it flattens as expected, but I didn't want to have to worry about the name changing in my logic so I prefer to just keep it a tiff... I would gues converting to jpg or png wouldn't even require the flatten option sense they can't handle layers....

But that's not what I'm trying to do, I just want to flatten a layered PS tiff... surprised this doesn't work tbh.

But at least I know it's not just my newbism to IM...

Thanks everyone for taing the time to help!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Can't flatten tif files???

Post by snibgo »

It seems there are different ways that Photoshop can save layers in tiff files. Sometimes they are saved as separate images, and IM can then see each one. But sometimes ("grouped layers"?) Photoshop saves the layers in such a way that IM, exiftool and Gimp can see only one layer.
snibgo's IM pages: im.snibgo.com
baraka2000
Posts: 5
Joined: 2013-11-21T10:49:42-07:00
Authentication code: 6789

Re: Can't flatten tif files???

Post by baraka2000 »

Another update:

I tried:

Code: Select all

convert Shot_03_Single_034.tif -flatten out.tif
But when I open the out.tif in PS I see all layers alive and kicking.

Looks like I'll have to live with the name change and go png...
baraka2000
Posts: 5
Joined: 2013-11-21T10:49:42-07:00
Authentication code: 6789

Re: Can't flatten tif files???

Post by baraka2000 »

#snibgo thanks for your insight.

I guess I'm surprised it doesn't just throw anything it can't see away... It must be doing that on some level when going to png...

I'll stick with the png solution I guess. Thanks everyone!

Hope this helps someone in the future as I googled my heart out trying to figure this one out...
Post Reply