Convert .tif with layers in .png

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
hank
Posts: 7
Joined: 2016-10-21T00:44:47-07:00
Authentication code: 1151

Convert .tif with layers in .png

Post by hank »

Hi,

i'm searching for a smart solution for converting tif files, cmyk, with 2 or more layers, without clipping path or any separate masks and no background (transparent) in a png with transparency

I found this here:
convert test_file.tif \( -clone 0 -alpha on -channel rgba -evaluate set 0 \) \( -clone 1 \) -delete 0,1 -background none -flatten test_file.png

It works for me, if my test file has just one layer... but usually our files have more than one.

Can anyone help me? Cause i don't really understand all parameters or scripting at all :-(

Thanks
hank
Posts: 7
Joined: 2016-10-21T00:44:47-07:00
Authentication code: 1151

Re: Convert .tif with layers in .png

Post by hank »

Oh, i'm using ImageMagick 6.9.6-2 Q16 x86_64 2016-10-21
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert .tif with layers in .png

Post by snibgo »

When you tiff has two layers, what output(s) do you want? Perhaps one png per layer, as if they were entirely separate images. Or perhaps you want a single png output, by combining the layers in some way.
snibgo's IM pages: im.snibgo.com
hank
Posts: 7
Joined: 2016-10-21T00:44:47-07:00
Authentication code: 1151

Re: Convert .tif with layers in .png

Post by hank »

The result should be a single png with the layers combined.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert .tif with layers in .png

Post by snibgo »

Okay. Combined in what way?

Perhaps:

Code: Select all

convert in.tif -layers merge out.png
snibgo's IM pages: im.snibgo.com
hank
Posts: 7
Joined: 2016-10-21T00:44:47-07:00
Authentication code: 1151

Re: Convert .tif with layers in .png

Post by hank »

Okay, the combination of the layers is right, thanks, but now my background ist white.
hank
Posts: 7
Joined: 2016-10-21T00:44:47-07:00
Authentication code: 1151

Re: Convert .tif with layers in .png

Post by hank »

if i try this
convert test.tif \( -clone 0 -alpha on -channel rgba -evaluate set 0 \) \( -clone 1 \) -delete 0,1 -background none -layers merge test.png

Almost everything looks fine, just the sequence of the layers is wrong
hank
Posts: 7
Joined: 2016-10-21T00:44:47-07:00
Authentication code: 1151

Re: Convert .tif with layers in .png

Post by hank »

I found the solution for my problem

convert test.tif \( -clone 0 -alpha on -channel rgba -evaluate set 0 \) -delete 0 -background none -layers merge test.png
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert .tif with layers in .png

Post by snibgo »

hank wrote:... but now my background ist white.
Then use "-background none":

Code: Select all

convert in.tif -background none -layers merge out.png
Glad you've found a solution, but it looks as if it will ignore the first image in the tiff.
snibgo's IM pages: im.snibgo.com
hank
Posts: 7
Joined: 2016-10-21T00:44:47-07:00
Authentication code: 1151

Re: Convert .tif with layers in .png

Post by hank »

-background none doesn't work.
Don't know why
Post Reply