Insert 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
loic.rapp
Posts: 5
Joined: 2015-10-30T02:49:42-07:00
Authentication code: 1151

Insert clipping path

Post by loic.rapp »

Hello,

Sorry, but I don't know exactly where I supposed to post my message. :D

I need to do something with ImageMagick: I have an empty image (JPEG) who contains an Photoshop clipping path.
With a

Code: Select all

identify -verbose $fileName
I can get the SVG clipping path code of my image (JPEG).

But now, I want to insert this clipping path into an other image (also a JPEG) who have no clipping path.
It is possible to do that with ImageMagick or not? If it's possible, how can I do that. I can show you an example if someone need it.

Have a good day!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Insert clipping path

Post by fmw42 »

IM can extract the clip path as an SVG (text) file. See http://www.imagemagick.org/Usage/masking/#clip_mask. But I do not think it can be transferred to another file. You can save the SVG clip path as an SVG file and then use it as a mask to apply to another file. See http://www.imagemagick.org/Usage/masking/#read_mask
loic.rapp
Posts: 5
Joined: 2015-10-30T02:49:42-07:00
Authentication code: 1151

Re: Insert clipping path

Post by loic.rapp »

I already get an SVG clipping path, with a script who works with identify -verbose.

But, I don't really understand the read mask part..
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Insert clipping path

Post by fmw42 »

I do not understand what exactly you are trying to do. Please explain in more detail. A clipping path from one image may not work for any other image. What do you want to do with the clipping path on the second image? Can you post your image that has the clipping path and the one you want to transfer it to and explain then how you want to use the clipping path on the second image? Is it to mask out some part of the second image?
loic.rapp
Posts: 5
Joined: 2015-10-30T02:49:42-07:00
Authentication code: 1151

Re: Insert clipping path

Post by loic.rapp »

I need to extract a clipping path from one image (as SVG for example), and I need to reimport it to an other one.
So, I have a low quality JPEG file with a Photoshop Clipping Path, with a

Code: Select all

identify -verbose /path/of/myimage.jpg
I get the clipping path and I use "cut, grep and awk" to create a ready-to-use SVG file.
So for now, I have:
- One low quality JPEG
- One SVG file who is the low quality JPEG clipping path
- One high quality JPEG

How can I import the clipping path of the low quality JPEG to the high quality JPEG file? With the SVG or directly the low quality JPEG.
loic.rapp
Posts: 5
Joined: 2015-10-30T02:49:42-07:00
Authentication code: 1151

Re: Insert clipping path

Post by loic.rapp »

UP!
loic.rapp
Posts: 5
Joined: 2015-10-30T02:49:42-07:00
Authentication code: 1151

Re: Insert clipping path

Post by loic.rapp »

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

Re: Insert clipping path

Post by fmw42 »

I am not an expert on clip paths. But I do not think IM can import clip paths from svg. As far as I know, it only exports clip paths.

Even if it could, the low res one would not work with the high res one. The clip path would not match on the high res one. You can apply the clip path as a mask, but I do not think it would match the high resolution image.
promonda
Posts: 3
Joined: 2019-06-14T05:14:26-07:00
Authentication code: 1152

Re: Insert clipping path

Post by promonda »

I am using Magick.NET to process image in C#. I want to embed/add a clipping path taken from a SVG file to my target image. The clipping path dimension and target image dimension is exactly same. I want it to be embedded into target image so that we can change the background outside of clipping path.

There is two method for Clipping path functionality in Magick.NET GetClippingPath() and SetClippingPath(). While GetClippingPath() works well for images having clipping path embedded, SetClippingPath() doesn't work at all.

Is it really possible to set clip path using Magick.NET, if so how I can achieve this.. Please help. I have a deadline to answer if it can be done or not.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Insert clipping path

Post by fmw42 »

Code: Select all

I am not an expert on clip paths. But I do not think IM can import clip paths from svg. As far as I know, it only exports clip paths.
promonda
Posts: 3
Joined: 2019-06-14T05:14:26-07:00
Authentication code: 1152

Re: Insert clipping path

Post by promonda »

Is it possible to add clipping path (from SVG) using ImageMagick command line or ImageMagick command also doesn't support it.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Insert clipping path

Post by fmw42 »

NO! ImageMagick cannot do that. Did you read the post above?
promonda
Posts: 3
Joined: 2019-06-14T05:14:26-07:00
Authentication code: 1152

Re: Insert clipping path

Post by promonda »

Ok. I read the above post, just checked if there is any new version that support this as the earlier post is quite older. Thanks for your reply.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Insert clipping path

Post by fmw42 »

Sorry, no updates and no plans for that as far as I know.
Post Reply