Masking Path problem with some IM versions

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
samfra
Posts: 3
Joined: 2013-08-22T08:42:33-07:00
Authentication code: 6789

Masking Path problem with some IM versions

Post by samfra »

Hello,

this bug appeared on a production server with Image Magick 6.4.

When I tried to test it on my computer with version 6.5.9-10 (2010-02-21), it was successful
Then I downloaded version 6.8.6-8 (2013-08-04 Q16) and it failed.

Here is the problem

I simply type
convert image.tif -resize 200x200 image.jpg

My picture is a watch.

With 6.4 and 6.8, the dial is missing on the transformed image
note : If I type convert image.tif image.jpg .. nothing is missing

With 6.5, my watch is perfectly resized.

any idea ? I can provide the file

thank you


Added on 08/27/2013:
I have opened Photoshop and I have discovered that there were paths AND masks.
I have removed all masks => the conversion works perfectly.
I have removed all paths => the conversion still fails

Conclusion, it's a masking issue, so I have renamed the title

the file can be downloaded here : http://www.utopix.ch/_z3c_/watch-mask.tif

thank you for your help
Last edited by samfra on 2013-08-27T03:37:41-07:00, edited 1 time in total.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Clipping Path problem with some IM versions

Post by snibgo »

Provide the file.
snibgo's IM pages: im.snibgo.com
samfra
Posts: 3
Joined: 2013-08-22T08:42:33-07:00
Authentication code: 6789

Re: Clipping Path problem with some IM versions

Post by samfra »

snibgo wrote:Provide the file.
here is the file http://www.utopix.ch/_z3c_/watch-mask.tif

I simple resize it :

convert watch-mask.tif -resize 200x200 output.jpg

I need to be able to handle such files (the programm must be generic)

thank you
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Masking Path problem with some IM versions

Post by snibgo »

You should ignore the alpha.

Code: Select all

convert watch-mask.tif -alpha off -resize 200x200 output.jpg
You might also want to convert it to sRGB, and strip all the non-image elements:

Code: Select all

convert watch-mask.tif -alpha off -colorspace sRGB -resize 200x200 -strip output.jpg
snibgo's IM pages: im.snibgo.com
samfra
Posts: 3
Joined: 2013-08-22T08:42:33-07:00
Authentication code: 6789

Re: Masking Path problem with some IM versions

Post by samfra »

Hello,

first, thank you very much for your help, I appreciate.

It solves my problem with this kind of pictures.
But my web application must be able to handle all kinds of pictures.

How could I know if I have to add "-alpha off" for a picture and not for a simple file where I'd like to keep the transparency.
(If it's not possible dynamically, which limit could I give to my customers ?)
Is there no way to do only a kind of "-mask off" ? :)

(in my example, I converted to jpg, but in fact, if I find some alpha channels, I convert to png).

thank you,
Sam
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Masking Path problem with some IM versions

Post by snibgo »

samfra wrote:How could I know if I have to add "-alpha off" for a picture and not for a simple file where I'd like to keep the transparency.
For some files, the alpha is important and you want to keep it. For others, like this one, you want to remove it.

You need to find what chacteristic determines whether you want to keep the alphas. Perhaps all the CMYKA files should have alpha off. Or perhaps files with "mask" in the name need alpha off. Perhaps files that have detail hidden by alpha should have alpha off, but where hidden pixels have a constant color you want to keep the alpha.

EDIT: Or perhaps files with tiff:alpha:unassociated should have alpha off.
snibgo's IM pages: im.snibgo.com
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Masking Path problem with some IM versions

Post by snibgo »

Reading posts on these forums about "unassociated" makes me strongly suspect this is the difference.

Modern versions of IM can:

Code: Select all

identify -quiet -format "%[tiff:alpha]" transparent.tif
This returns nothing or "associated" or "unassociated". You may find that testing this, and setting "-alpha off" for "unassociated", does what you want.

In old IM versions, you need to "identify -verbose" and search for "tiff:alpha".
snibgo's IM pages: im.snibgo.com
Post Reply