Select more than one layer from TIFF and output a flattened JPG

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
thdbased
Posts: 3
Joined: 2018-04-04T04:59:34-07:00
Authentication code: 1152

Select more than one layer from TIFF and output a flattened JPG

Post by thdbased » 2019-06-05T07:59:11-07:00

I have an input file, the file itself I cannot share due to the contents.
The file is a TIFF which contains 4 layers:

Code: Select all

.\image.tif[0] TIFF 4166x3315 4166x3315+0+0 8-bit sRGB 102.1MB 0.250u 0:00.243
.\image.tif[1] TIFF 4166x3315 4166x3315+0+0 8-bit sRGB 102.1MB 0.016u 0:00.028
.\image.tif[2] TIFF 2920x106 2920x106+669+2996 8-bit Grayscale Gray 102.1MB 0.016u 0:00.044
.\image.tif[3] TIFF 2873x2788 2873x2788+672+309 8-bit sRGB 102.1MB 0.016u 0:00.059
I want to take the first two layers and have a JPG output with those two layers flattened as a result.
I can take each layer individually without a problem, but more than one I cannot find how.

Many thanks :)

snibgo
Posts: 12174
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Select more than one layer from TIFF and output a flattened JPG

Post by snibgo » 2019-06-05T08:34:58-07:00

Code: Select all

magick image.tif[0] image.tif[1] -layers Flatten out.jpg
snibgo's IM pages: im.snibgo.com

thdbased
Posts: 3
Joined: 2018-04-04T04:59:34-07:00
Authentication code: 1152

Re: Select more than one layer from TIFF and output a flattened JPG

Post by thdbased » 2019-06-05T09:33:57-07:00

Thx, will give that a try.

User avatar
GeeMack
Posts: 719
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Select more than one layer from TIFF and output a flattened JPG

Post by GeeMack » 2019-06-05T11:05:11-07:00

thdbased wrote:
2019-06-05T09:33:57-07:00
Thx, will give that a try.
The answer snibgo gave above is about as simple as you can get. Keep in mind you can include more than one index inside the square brackets, and those indexes can be in the order you want to read the images. This command would read in the second image before the first...

Code: Select all

magick image.tif[1,0] -layers Flatten out.jpg
In other words, the first two images will be read with that command in the order 1 then 0, so the second image will be flattened onto the first.

Post Reply