Crop to 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
masterbp
Posts: 27
Joined: 2007-10-08T06:23:33-07:00

Crop to clipping path

Post by masterbp »

Hi

I have images with white background and a clipping path - see example here: http://resources.jysk.com/getimage/pm.l ... 1/WEB/1001

I would like to crop the photo so the closet in the photo takes up as much space as possible. It must be the clipping-path that defines the left, right, top, bottom coordinate for the crop.

Is this possible in a simple way with ImageMagick?

Best regards,

Benny Pedersen
zaratol
Posts: 43
Joined: 2010-04-21T08:30:43-07:00
Authentication code: 8675308

Re: Crop to clipping path

Post by zaratol »

Out of curiosity:

is this even possible at all with IM?

because all command lines i have seen so far are using the path information to change the color outside and trim to actually shrink the image.

But to use the clipping path so that the canvas of the new image touches the outside of the path, and not to change pixels outside the clipping path, that are still visible - i would not know how to do it
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Crop to clipping path

Post by anthony »

I would clip the image, or at least a copy or trash image. then use -trim and output the crop parameters the trim came up with.

after that you can use those parameters to crop the original image.

It is similar to a sort of 'fuzzy trim' technique for noisy images.
http://www.imagemagick.org/Usage/crop/#trim_blur
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply