serverless-image-proxy icon indicating copy to clipboard operation
serverless-image-proxy copied to clipboard

Example with crop center: x and y center cropping

Open kenyk7 opened this issue 7 years ago • 3 comments

kenyk7 avatar Oct 02 '17 21:10 kenyk7

I also got this requirement. +1

Basically, the API already allows for cropping, positioning and resizing, but it doesn't pipe it or take the order into account.

e.g. let's say there's an image with an unknown size uploaded by a user. Let's say the actual size (unknown to the code / dev) is 4000 x 8000 pixels.

If I want to get a squared image in the center and resizing it to 200 pixels, I'd need it to resize to 200x400 first and then crop the top and bottom 100 pixels to get a 200x200 image.

using the api currently allows us to call image-url/200x/0x100:200x200

The problem here is I don't know that I need to fill in 100 to crop the top 100 pixels off or 0 to not crop the width, as I don't have the original image's dimensions. The other problem is that when it crops, it doesn't seem to crop the resized 200x400 image, but rather the original 4000 x 8000 image. The result is that I get the very top left zoomed in 200x400 pixels in the image which is not what I want.

cyrus-za avatar Oct 18 '17 16:10 cyrus-za

this would be very helpful. Maybe the best would be even to publish the ratio of an image beside the type and all other values

dohomi avatar Oct 20 '17 00:10 dohomi

It would be great to support the cropping features of sharp: http://sharp.pixelplumbing.com/en/stable/api-resize/#crop

dohomi avatar Mar 05 '18 08:03 dohomi