Write four band image

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
Posts: 1
Joined: 2018-12-04T17:48:21-07:00
Authentication code: 1152

Write four band image

Post by MurrayW » 2018-12-06T00:10:20-07:00

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.


User avatar
Posts: 24097
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Write four band image

Post by fmw42 » 2018-12-06T00:19:20-07:00

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.

Post Reply