(SOLVED) Problem with -define tiff:alpha=associated

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
lukefwkr

(SOLVED) Problem with -define tiff:alpha=associated

Post by lukefwkr »

Hello dear ImageMagicians,

i have to convert a transparent .PNG file for printing issues to .TIFF format with associated alpha channels using following syntax:

convert -colorspace CMYK -define tiff:alpha=associated ./image1.png ./image1.tiff

But for some reasons all the .tif files, that get generated the Alpha Channel is still present. How ever there is some strange behaviour that accours:

On running the upper command and identifying the image via identify -verbose i am getting the following results:

Image: associated.tif
Format: TIFF (Tagged Image File Format)
Class: DirectClass
Geometry: 332x144+0+0
Resolution: 72x72
Print size: 4.61111x2
Units: Undefined
Type: ColorSeparationMatte
Base type: ColorSeparation
Endianess: MSB
Colorspace: CMYK
Depth: 8/16-bit
Channel depth:
cyan: 1-bit
magenta: 16-bit
yellow: 16-bit
black: 8-bit
alpha: 8-bit
.....
Properties:
date:create: 2010-08-11T10:30:48+02:00
date:modify: 2010-08-11T10:30:48+02:00
signature: d33166bdd154aa9772e56b53ad1bb9c57d0c5ca9f00d718e8555d8e17c14afaf
tiff:alpha: unassociated
tiff:document: associated.tif
tiff:photometric: separated
tiff:rows-per-strip: 144
tiff:software: ImageMagick 6.6.0-4 2010-08-05 Q16 http://www.imagemagick.org

So i wanted to see, what happenes, if i run the command using the alpha:unassociated define:

Image: unassociated.tif
Format: TIFF (Tagged Image File Format)
Class: DirectClass
Geometry: 332x144+0+0
Resolution: 72x72
Print size: 4.61111x2
Units: Undefined
Type: ColorSeparationMatte
Base type: ColorSeparation
Endianess: MSB
Colorspace: CMYK
Depth: 8-bit
Channel depth:
cyan: 1-bit
magenta: 8-bit
yellow: 8-bit
black: 8-bit
alpha: 8-bit
.....

Properties:
date:create: 2010-08-11T10:31:19+02:00
date:modify: 2010-08-11T10:31:19+02:00
signature: 8a7f44b45393be754014ddaf3df4f557883c97e20666ccd4dc0cd069575e96b9
tiff:alpha: unassociated
tiff:document: unassociated.tif
tiff:photometric: separated
tiff:rows-per-strip: 144
tiff:software: ImageMagick 6.6.0-4 2010-08-05 Q16 http://www.imagemagick.org

The thing i really dont understand is, why does my "associated" image has a 16bit magenta and yellow channel, while the "unassociated" image still is 8 bit?

Both images get identified as unassociated.

I´m running ImageMagick on Debian Lenny 32bit with up to date Libraries. (using aptitude update and dist-upgrade)

identify -list format gets:
TIFF* TIFF rw+ Tagged Image File Format (LIBTIFF, Version 3.8.2)
TIFF64* TIFF --- Tagged Image File Format (64-bit) (LIBTIFF, Version 3.8.2)

ImageMagics documentation says using -define tiff:alpha requires Tiff 3.6.1 or higher (requirement filled)

i also tried running other defines like -define tiff:rows-per-strip:1 because i wanted to see if it affects the image as less as the -define tiff:alpha=associated/unassociated parameter.

Well - it does :-) For some reason there is not anything in the identify -verbose log, i defined when running any -define tiff:..... parameter. This is a real strange behaviour, but it anyhow affects the color-depth of the magenta and yellow channel.

Because latest ImageMagick version in debian lenny repository was 6.3.9 i decided to use the instructions from the following url to build a backport using the sources from debian squeeze:

http://serverfault.com/questions/154598 ... bian-lenny

On another Debian Lenny testing environment i used the following method to install the same ImageMagick Version from squeeze binary repository:

http://serverfault.com/questions/22414/ ... om-testing

Both envorimnents have now the same ImageMagick Version: 6.6.0-4.

My next try would be using Ubuntu 10.04 with their latest ImageMagick Version and if this also does not work finally doing a complete compile using the latest sources from imagemagick.org.

If someone else could test the occurances with a transparent .png with the latest imagemagick version and giving the results here would be great for helping.

Fyi: I was using the following .png file for testing command:
http://c1.www.taktfoll.de/design/images ... ktfoll.png

Thank You and Greetings

L.F.

Update: Same behaviour on Ubuntus 10.04 Packet of ImageMagick (v6.5.7-8)

Update 2: I just downloaded ImageMagick-6.6.3-4-Q16-windows-static.exe and tested the command line on this one - and guess what: yes, it´s exactly the same behaviour as above described. None of the "-define tiff:...." parameters gets processed.

Now i am quite sure this must be either a really stupid usage problem on my side or it is simply a bug!
Last edited by lukefwkr on 2010-08-13T07:34:08-07:00, edited 1 time in total.
Drarakel
Posts: 547
Joined: 2010-04-07T12:36:59-07:00
Authentication code: 8675308

Re: Problem with -define tiff:alpha=associated

Post by Drarakel »

The "-define" options 'behave' a bit strangely sometimes, yes - especially the one for "tiff:alpha" (actually, that's the "ExtraSamples" EXIF tag).
But they do work.

First, you have to make sure that the define really gets used. With "tiff:alpha", a current ImageMagick will only change it if there is already such a tag. So, first convert the image (with alpha layer) to TIFF. Then change the properties of the alpha. You could do it in one commandline - for example like that:

Code: Select all

convert image1.png TIFF:- | convert -define tiff:alpha=associated - -colorspace CMYK image1.tif
Or change it from "unassociated" to "associated" like that (not really necessary in this case, but perhaps in other cases..):

Code: Select all

convert image1.png -colorspace CMYK -depth 16 TIFF:- | convert -define tiff:alpha=associated - -depth 8 image1.tif
Now you should have an 8bit per channel TIFF with associated alpha.
Your other 'problem' is how it gets displayed in ImageMagick. But you shouldn't be worried about the fact that IM shows the alpha as "unassociated" in the info from "identify -verbose". IM will convert the image internally from "associated alpha" to "unassociated alpha" when it reads such an image. The info from (a current) ImageMagick will always show the alpha in TIFF as "unassociated". But as I said, the file itself is fine (and has associated alpha). You just have to be careful when you're doing another conversion on that file with IM, as the channels will also be converted to "unassociated" again.

Regarding the "16-bit" channels: Well, IM has to convert the normal color channels when it goes from "associated" to "unassociated". And that might generate 16-bit values (if you're using a Q16 version of IM). A bit strange though, that the depth of some channels is displayed as "16-bit", but the channel statistics and the histogram show only 8-bit values...

lukefwkr wrote:i also tried running other defines like -define tiff:rows-per-strip:1 because i wanted to see if it affects the image as less as the -define tiff:alpha=associated/unassociated parameter.
With "rows-per-strip", it's different. I didn't use that define option much before, but after a few tests it seems that in IM this works only with certain compressions in TIFF. With ZIP (and some other compressions), the rows-per-strip seem to be hardcoded (not changeable). It works only with RLE, LZW and no compression. Example:

Code: Select all

convert -define tiff:rows-per-strip=1 image.png -compress lzw image.tif
lukefwkr

(Solved) Re: Problem with -define tiff:alpha=associated

Post by lukefwkr »

Thank you very much for your comprehensive explanation! You just saved my day.
As my boss would say: "Lob und Anerkennung!" - Praise and compliments! (i hope my translation is correct ;-))

Best regards from Germany,

L.F.
Post Reply