convert -alpha off creates strange TIFF

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
Andi34
Posts: 7
Joined: 2018-10-28T06:46:35-07:00
Authentication code: 1152

convert -alpha off creates strange TIFF

Post by Andi34 » 2018-10-31T11:35:03-07:00

I completely remove the alpha channel of a TIFF resulting from a tool that will only output 4-channel TIFFs by

Code: Select all

convert inputimg -alpha off outputimg
(It seems to work well with the same file as input and output.)

The problem is that Mac OS' (10.11) Finder preview will only show a completely black file while Lightroom shows the correct file contents. On the other side, a TIFF with 3 channels, exported from Lightroom will appear correctly in preview.

Now I create a cropped TIFF from both files, from the original 4-channel and the 3-channel TIFF:

Code: Select all

convert 4channel.tif -crop 400x400+200+200 4channel_clip.tif
convert 3channel.tif -crop 400x400+200+200 3channel_clip.tif
Result is that both clipped files will show correctly in preview. So what is wrong with the TIFF file resulting from -alpha off? I don't want to create separate preview JPEGs for all my TIFFs.

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

Re: convert -alpha off creates strange TIFF

Post by fmw42 » 2018-10-31T15:54:46-07:00

Many viewers will not display CMYK TIFF well unless there is a color profile imbedded. Is your original TIFF CMYKA or was it RGBA. When you remove the alpha it will leave the area under the alpha with the way the input was created. Often that means that those pixels were color/alpha, that is they were not the nominal black/alpha.

Typically at least with RGBA, when I want to remove the alpha, I set the alpha background to black first, like

Code: Select all

convert image -background black -alpha background -alpha off result
or

Code: Select all

convert image -background black -flatten result

________________

Please, always provide your IM version and platform when asking questions, since syntax may differ.

Also provide your exact command line and your images, if possible.

See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at http://www.imagemagick.org/discourse-se ... f=1&t=9620

If using Imagemagick 7, then see http://imagemagick.org/script/porting.php#cli


For novices, see

http://www.imagemagick.org/discourse-se ... f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
https://github.com/ImageMagick/usage-markdown
https://imagemagick.org/script/porting.php#cli

Andi34
Posts: 7
Joined: 2018-10-28T06:46:35-07:00
Authentication code: 1152

Re: convert -alpha off creates strange TIFF

Post by Andi34 » 2018-11-04T17:24:42-07:00

It seems that Mac OS' Finder cannot deal with large TIFFs (in my case > 5000x3000) that are LZW compressed. The "enfuse" utility creating the original file produced an LZW compressed 4-channel 16-bit TIFF (despite called with --compression=none) which is a bad choice. identify -verbose is very helpful finding such issues.

Post Reply