-clip wrongly assumes that first path is clipping path

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
fredrik@axpa.se

-clip wrongly assumes that first path is clipping path

Post by fredrik@axpa.se »

This may not technically be a bug, but the functionality does not allow the actual image properties to determine the behaviour which means that it is at least a hardcoding issue.

This is my problem:
When using "-clip" the first path in the 8BIM profile is applied as the image clipping path.

BUT:
  • Images can have many concurrent paths.
    A path does not have to be a clipping path.
    The clipping path does not have to be the first path.
In Photoshop it is possible to tag one (1) path as "is clipping path".
(It is not necessary to do so, you can have 10 paths in your image and none of them is clipping.)

I would expect -clip to apply the designated clipping path in the 8BIM profile, not the first path.
If none of the paths in the profile is designated "is clipping path" I would expect -clip to do nothing.

If I want to use a different path for clipping I can use -clip-path thePath instead.
But I have not been able to ask an image what paths it contains.
I have not found an identify switch that returns the list of paths in the 8BIM profile.
Is this possible?
fredrik@axpa.se

Re: -clip wrongly assumes that first path is clipping path

Post by fredrik@axpa.se »

I have uploaded a couple of examples that demonstrate this issue.
These are two versions of the same file with different clipping path settings.
The first file "7_paths_none_clipping.psd" contains 7 paths, but none of them is set as a clipping path in Photoshop.
The second file "7_paths_no3_clipping.psd" contains the same 7 paths, but here path #3 (Path 3) has been used as the clipping path in Photoshop.
http://www.box.net/shared/0iaub9pf1u
http://www.box.net/shared/124c48u44i

This is the conversion I want to do.
I have split it into 4 converts where I keep the intermediary files for clarity:
Step 1: Flatten the .psd file by extracting the first scene:

Code: Select all

convert 7_paths_none_clipping.psd[0] pv_tmp.tif
Step 2: Convert to RGB, limit to 1000 px and make transparent outside clipping path:

Code: Select all

convert pv_tmp.tif -profile "C:\Program Files\ImageMagick\config\AdobeRGB1998.icc" -background white -fill white -draw "color 0 0 reset" -transparent white -clip -draw "Image Copy 0,0 0,0 pv_tmp.tif" -geometry 1000x1000 -strip pv_tmp.png
Step 3: Overlay on white background and save as a JPEG for presentaions use:

Code: Select all

convert pv_tmp.png -fill white -draw "color 0,0 floodfill" pv_ppt.jpg
When I run the conversions on the 2 test images I get the exact same result for both, which is not what I intended and not what the images actually specify.

Best regards
Fredrik
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: -clip wrongly assumes that first path is clipping path

Post by magick »

We will investigate but currently we do not know if there is a method to identify the default clipping path from a set of clipping paths. That is why we introduced -clip-path so the user can specify which clip path to use.
fredrik@axpa.se

Re: -clip wrongly assumes that first path is clipping path

Post by fredrik@axpa.se »

I don't have the tools to read the 8BIM profile properly, but if you dump the profile with different clipping paths set in Photoshop you will see that path's name towards the end of the profile.

-clip-path is great, but if I cannot read which paths a profile contains it is impossible to choose the correct one.
Unfortunately I am not in a position to enforce a naming convention on the paths.
fredrik@axpa.se

Re: -clip wrongly assumes that first path is clipping path

Post by fredrik@axpa.se »

Do you have any news on this?

I am unwilling to let it go since it is of great importance to me.
Post Reply