identify -verbose lists Clipping Path

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
alea
Posts: 5
Joined: 2012-10-11T06:30:49-07:00
Authentication code: 67789

identify -verbose lists Clipping Path

Post by alea »

Hello,

I'm using ImageMagick to automate file downloads from an image database. ImageMagick is running on a unix system and I wrote a small perl script which converts the inputfile to 144 dpi png file, no matter which image type (tiff, eps-jpeg, jpg ... ) is downloaded. In the script I use two different convert commands depending on the fact if the image has a clipping path or not. So I use

Code: Select all

identify -verbose $inputfile
and exam the output.

Now I've tried this perl script with different files and I found a problem in my approach with a tiff file. It includes 6 paths but none of those paths were defined as clipping path. When using the above command the resulting output is the following (reduced to the interesting parts):

Code: Select all

Image: SH_XP_35150_12.tif
  Format: TIFF (Tagged Image File Format)
  Class: DirectClass
...
  Clipping path:
<?xml version="1.0" encoding="iso-8859-1"?>
<svg width="5616" height="3744">
<g>
<path style="fill:#00000000;stroke:#00000000;stroke-width:0;stroke-antialiasing:false" d="
M 3679,489
L 3679,-95
L 852,-303
L -222,-249
L -309,702
L 1806,831
L 3678,789
"/>
</g>
</svg>
....
  Version: ImageMagick 6.6.2-10 2012-02-03 Q16 http://www.imagemagick.org
Is that a normal behaviour even if no path was defined as clipping path? Usually I would say I don't mind but because of the Clipping path entry I use the command:

Code: Select all

convert SH_XP_35150_12.tif -resample 144x144 -alpha transparent -clip -alpha opaque -strip -depth 8 mytest.png
The result is very odd. It simply uses the first path (in photoshop list) as clipping path.

I would be very glad if someone can give me a hint of what I'm doing wrong. If you need any more information to answer my question or to help me, please ask.

Thanks a lot :)

Alea
alea
Posts: 5
Joined: 2012-10-11T06:30:49-07:00
Authentication code: 67789

Re: identify -verbose lists Clipping Path

Post by alea »

Has noone an idea why identify -verbose lists my paths as clipping path?

Alternatively: Maybe someone has an idea how to get the information if the image file contains a clipping path or not in a different way.

Any help or hints would be really appreciated.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: identify -verbose lists Clipping Path

Post by fmw42 »

How are you detecting a clipping path? Can you provide a link to an example image?

For extracting the clipping paths, they may be listed in the verbose info as xml data or contained in the 8bim profile. To extract from the profile see http://www.imagemagick.org/Usage/masking/#clip
alea
Posts: 5
Joined: 2012-10-11T06:30:49-07:00
Authentication code: 67789

Re: identify -verbose lists Clipping Path

Post by alea »

Hello,

I assume if identify -verbose outputs

Clipping path: ... etc. that the file contains a clipping path. Is this wrong?

This is the example file
https://web.emmet-software-labs.com/tes ... stfile.zip

Thanks a lot.
Alea
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: identify -verbose lists Clipping Path

Post by fmw42 »

Clipping paths can also be contained in the 8bim profiles. You can access them directly. See

http://www.imagemagick.org/script/comma ... #clip-path
http://www.imagemagick.org/Usage/masking/#clip
alea
Posts: 5
Joined: 2012-10-11T06:30:49-07:00
Authentication code: 67789

Re: identify -verbose lists Clipping Path

Post by alea »

Maybe I misunderstood something but I simply want to find out if an image contains a clipping path. This is used in a script like:

Code: Select all

$has_image_clip_path = `identify -verbose "$infile" | grep "Clipping path:"`;
if($has_image_clip_path) {
   <some convert command using -clip etc.>
}
else {
    <some other convert command without -clip>
}
Even if the image does not contain any active clipping path, the variable is filled with the String "Clipping path:". So my code does not work. I'm ready to use another approach but so far I can't think of any other.

I also tried

Code: Select all

identify -format '%[8BIM:1999,2998:#1]' image_clip.tiff
, but that outputs also the path although it is not active.
alea
Posts: 5
Joined: 2012-10-11T06:30:49-07:00
Authentication code: 67789

Re: identify -verbose lists Clipping Path

Post by alea »

It helps if I use this command. it only outputs something, if the path is a clipping path.

Code: Select all

identify -format '%[8BIM:2999,2999:#1]' <myimage>
estyx
Posts: 1
Joined: 2013-04-12T04:55:40-07:00
Authentication code: 6789

Re: identify -verbose lists Clipping Path

Post by estyx »

Is there a easy way to determine if a image file have clipping path(s) stored as SVG data? (8bim is not a problem) Using Windows XP batch files so kinda limited commands vs *NIX.
zao2k
Posts: 2
Joined: 2019-03-25T04:21:41-07:00
Authentication code: 1152

Re: identify -verbose lists Clipping Path

Post by zao2k »

Hi all,

Thanks for your thread, already very helpful. I have one issue though. Some of my images contain path that are not set to clipping paths. what happens then is that identify "fails" on seeing the paths then and I end up with false negatives.

Is there a way to catch paths whatever they are clipping or not ?

Here is a link if you want to download a file to see what I mean :
http://dl.free.fr/o4WfEpCQR

Thanks in advance for your help.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: identify -verbose lists Clipping Path

Post by snibgo »

IM can not see any paths in your linked file demo.psd.
snibgo's IM pages: im.snibgo.com
zao2k
Posts: 2
Joined: 2019-03-25T04:21:41-07:00
Authentication code: 1152

Re: identify -verbose lists Clipping Path

Post by zao2k »

That's the point. There is one however.

Image

But because it's not set as clipping path IM won't see it. I am looking at a way to spot any possible vector path regardless it's a clipping path or not.

Thanks anyway for entering in.
Post Reply