Sharp: How crop works?

Created on 24 Dec 2016  路  4Comments  路  Source: lovell/sharp

Hi,

I couldn't figure out if I can crop at arbitrary points, similarly as with ImageMagick/GraphicsMagick:

crop
Crops the image to the given width and height at the given x and y position.

gm("img.png").crop(width, height, x, y)

So, I would like to crop a small portion of an image at exactly x, y. Is this possible?

Thanks.

question

Most helpful comment

Hello, you're not the first to run into the *magick crop vs libvips extract confusion.

I expect the existing crop function to soon be deprecated, instead becoming an optional parameter of the resize operation. Whether we (eventually) recycle crop to become a synonym for extract remains to be seen :)

All 4 comments

I just realized, that extract() seems to do what I was asking.

I'll close this now as it's resolved. However, it's not totally clear what crop now does then :) Maybe make it more clear and point to the extract function from where the crop is explained?

Hello, you're not the first to run into the *magick crop vs libvips extract confusion.

I expect the existing crop function to soon be deprecated, instead becoming an optional parameter of the resize operation. Whether we (eventually) recycle crop to become a synonym for extract remains to be seen :)

@lovell any update on this? I think it's pretty confusing to everyone coming from any kind of photo manipulation tool to have an API called crop that doesn't accept coordinates. Extract doesn't seem very intuitive either as the method for "cropping with coordinates" as indicated by a few Issues that ask how to crop with coordinates.

Please subscribe to #1135 for updates.

Was this page helpful?
0 / 5 - 0 ratings