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?".

It seems that ImageMagick turns a regular alpha channel into an associated alpha channel if a converted image has only grayscale color values despite being an RGB image.
How to force the conversion process not to change the output color space and most importantly keep an alpha channel unassociated?

I'm looking for a command line and Magick++ solutions but it seems like Magick++ cannot read Photoshop TIFFs so just the command line would be fine.

But when converting an RGBA image containing only grayscale values things start to get weird.

Using associated and unassociated options produce only associated alpha channel.
The channel differs slightly between both options which is probably the result of alpha multiplication or something like that (sorry, not an expert at that).
Using unspecified option inexplicably does produce the unassociated alpha channel which is actually what I'm looking for.

A part of the confusion can be attributed to using XnView as an image viewer.
It's a decent image viewer and it never gave me any trouble but the thing is that after the conversion it shows that the converted images do not have alpha channels which just might be a bug because the Photoshop does recognize the alpha channels.

The problem now as I've mentioned is that I can't seem to retain RGB color space of the original image if the image has only grayscale color values.
Every conversion operation ends up with it being converted to grayscale.
Specifying -colorspace RGB doesn't work. Which is unusual since specifying -colorspace CMYK does work.

ImageMagick will change colorspace to gray for those formats that support it if the image is completely gray. But you can often force RGB for certain output types. Try adding -type truecolor to your command if your output is tif.

It looks like -type truecolor does work.
True, it discards alpha channel completely and using -type truecolormatte does just the opposite by forcing an alpha channel in images which don't have one initially but it's good solution for now.

I'm still not happy about IM converting images to grayscale without asking.

truecoloralpha does work in a way but it still generates an empty alpha channel for images with no alpha channels and I prefer it wouldn't do that. It's Ok for now though -- I have a non-IM related solution.
(btw., I don't believe that truecoloralpha is mentioned in command line options reference)

If you do not want the alpha channel created, then just use -type truecolor. If you want an existing alpha channel to be kept then use -type truecoloralpha. You could create a conditional testing on whether the input has an alpha channel so as to decide which form of -type you should use.