Get Clipping Path (as opposed to applying it)

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
lavie
Posts: 6
Joined: 2011-08-29T04:38:23-07:00
Authentication code: 8675308

Get Clipping Path (as opposed to applying it)

Post by lavie »

I've already figured out how to apply a clipping path embedded in the image file, using the "-clip" option.

My quesion is: is there a way to extract the clipping path - either as a memory struvture, stream, file, etc in some easily understood format (preferably an array of Bezier curves).

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

Re: Get Clipping Path (as opposed to applying it)

Post by fmw42 »

I have no experience with clip paths. But you might look at the verbose information for your image to see if it contains the clip path.

identify -verbose yourimage
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Get Clipping Path (as opposed to applying it)

Post by anthony »

The clip path is just a SVG path in the image meta-data. Identify with verbose should report it.

However the -clip is only used as a bitmap image (50% thresholded).


What little notes I have on it is in
IM Examples, Masking, Clipping Masks
http://www.imagemagick.org/Usage/maskin ... ping_masks
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
lavie
Posts: 6
Joined: 2011-08-29T04:38:23-07:00
Authentication code: 8675308

Re: Get Clipping Path (as opposed to applying it)

Post by lavie »

Hi Anthony,

Would the command you give (verbose) just give the name of the clipping path, or would it extract the actual array of Bezier curve points from the Adobe 8BIM clipping path?

TIA,
Lavie
lavie
Posts: 6
Joined: 2011-08-29T04:38:23-07:00
Authentication code: 8675308

Re: Get Clipping Path (as opposed to applying it)

Post by lavie »

OK - I just tried this, and I am getting what appears to be an array of points, I assume that this is the info I need.

However, I want to access this info via an API from a lib linked into my code, and not via command-line, which would be grossly inefficient for large volumes of SVG extraction. how would I go about that?

TIA,
mlavie
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Get Clipping Path (as opposed to applying it)

Post by anthony »

A SVG path can consist of an array of points, but not just points on the path ('knots' points) but also various control points to define the bezier curves also should contain some letters.
Something like...

Code: Select all

      M 12,27  C 7,37  18,50 18,60  S  0,80 10,94
       S 40,74 50,78  S 60,99 76,95  S 72,70 75,65
       S 95,55 95,42  S 69,37 66,32  S 67,2  53,7
       S 43,17 35,22  S 17,17 12,27  Z
The meaning of the letters is explained in
IM Examples, Drawing, SVG
http://www.imagemagick.org/Usage/draw/#paths

Or a less easy to follow but official explanation in the SVG specification
http://www.w3.org/TR/SVG/paths.html#Pat ... nformation
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
lavie
Posts: 6
Joined: 2011-08-29T04:38:23-07:00
Authentication code: 8675308

Re: Get Clipping Path (as opposed to applying it)

Post by lavie »

Hi Anthony,

I already managed to succeed with that - thanks for the "-verbose" tip.

How would I extract that same SVG info via an API call?

TIA,
mlavie
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Get Clipping Path (as opposed to applying it)

Post by anthony »

Sorry I am not sure about that. I don't use an actual API very often.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply