Page 1 of 1

Write four band image

Posted: 2018-12-06T00:10:20-07:00
by MurrayW
Hi all,

This must be such a simple question for most of you. believe me I have searched for an answer, but I suppose I am just very new to ImageMagick,

When combining four individual sinlge band tifs to create a four band tif, How to I designate a fourth band to be just another layer of pixel values, and to NOT be interpreted as an Alpha band?

Similar to this (from here: https://www.imagemagick.org/script/comm ... hp#combine )

convert sepimage-0.tif sepimage-1.tif sepimage-2.tif -channel RGB \ -combine imagecopy.tif

But for four bands I am guessing something like this, with a letter (perhaps) to designate the fourth band?

convert sepimage-0.tif sepimage-1.tif sepimage-2.tif sepimage-3.tif -channel RGB? \ -combine imagecopy.tif

I have used:

convert sepimage-0.tif sepimage-1.tif sepimage-2.tif sepimage-3.tif -combine imagecopy.tif

And it works for the RGB layers, but the output includes an EXIF tag called "Extra Samples - Unassociated Alpha", which I believe is interpreted by most apps to mean that the fourth band is an Alpha channel.

Cheers
Murray

Re: Write four band image

Posted: 2018-12-06T00:19:20-07:00
by fmw42
ImageMagick cannot write 4 channels to an RGB image using -combine. The fourth channel would be the alpha channel and it is added by -compose copy_opacity -composite. You can combine 4 channels as CMYK, if you want, but not RGB.

ImageMagick (6) does not write to multi-channel TIFF files right now as far as I know. It will write to multipage TIFF files by simply,

Code: Select all

convert image1.tif image2.tif image3.tif image4.tif result.tif
See also https://imagemagick.org/script/command- ... php#define for -define tiff:alpha=associated|unassociated|unspecified for alpha specification

In ImageMagick 7, you can combine multiple channels as miff, but you cannot yet save as tiff.

Re: Write four band image

Posted: 2018-12-11T18:55:26-07:00
by MurrayW
Thanks very much, I shall stop searching.

The alpha setting is useful and I am using it now. Which leads to another question, but I'll start a new topic.