Page 1 of 1

How to ignore alpha channel?

Posted: 2010-10-06T22:18:13-07:00
by cmcfarling
I need to convert a CMYK TIFF that contains an alpha channel to JPEG. My original command was

Code: Select all

convert -resample 72x72 -resize "1024x1024>" -units PixelsPerInch -quality 95 test.tif test.jpg
I've used this for a while on images that do not contain an alpha channel with no problems. However if the TIFF contains an alpha channel then the output file has unsmooth, pixelated edges. Here are some samples:

orig: http://www.50amp.com/im/alphatest.tif
what it should look like: http://www.50amp.com/im/alphatest-good.jpg
what it shouldn't look like: http://www.50amp.com/im/alphatest-bad.jpg

I've tried several options to try to keep IM from interpreting the alpha channel but have had no luck. For example:

Code: Select all

convert -resample 72x72 -resize "1024x1024>" -units PixelsPerInch -quality 95 test.tif -alpha off test.jpg
This gives the same bad result. Shouldn't 'alpha off' force IM to ignore the alpha channel?

Code: Select all

convert -channel CMYK -resample 72x72 -resize "1024x1024>" -units PixelsPerInch -quality 95 test.tif test.jpg
I tried this in an effort to force IM to operate only on the CMYK channels however this produces the same bad result.

Am I making syntax errors or do these operators just no do what I'm thinking they do?

Re: How to ignore alpha channel?

Posted: 2010-10-07T06:16:07-07:00
by anthony
You have to remove the transparency, generally but 'flattening' the image onto soem background color.

See IM Examples, Common File Formats, JPEG transparency - NOT
http://www.imagemagick.org/Usage/formats/#jpg_trans

Re: How to ignore alpha channel?

Posted: 2010-10-07T19:32:58-07:00
by cmcfarling
The -flatten operator seems to work in this case. I'm still curious why the -alpha Off operator wouldn't accomplish this. A command such as -channel CMYK also seems like it should accomplish this. Based on the documentation it seems that either of these operators should do something in this case, however neither have an effect. If anyone cares to elaborate I'd like to hear.

Re: How to ignore alpha channel?

Posted: 2010-10-08T00:30:55-07:00
by anthony
alpha off removes transparency, but does not specify what the transparency should be replaced with. It may be randome garbage. That is hidden fully-transparent colors left over from image building and masking.

better to flatten or border the image to overlay it onto some solid color background.