Resize and Crop an image using a single convert() action
Asked Answered
C

2

9

I'm currently looking to try and create a simple image uploader application which allows a user to load a picture from their desktop, select a crop area (using jcrop) in a specific aspect ratio, and then have filepicker.io crop to the defined dimensions and resize down appropriately.

The users will be uploading a picture of unknown dimensions, selecting an area that is in 10:13 ratio (width x height) and then filepicker needs to crop their image before resizing it to 100x130px.

Currently I have to perform 2 separate convert actions to crop and resize the image, which takes additional time and seems less efficient than it could be. Is there any way to combine crop and resize into a single action?

To get an idea of what I'm after, I would like this command to return an image 100x130 cropped to my ideal size:

/convert?crop=546,119,412,36&w=100&h=130

Catlin answered 20/6, 2013 at 20:19 Comment(1)
There doesn't look like there is a way to do that in one call.Homerus
B
3

You can see a note on their documentation about the topic:

Crop and Resize: we strongly recommend against combining a resize (specifying width or height) with the crop functionality, as it has indeterminant effects depending on whether the crop is applied before or after the image is resized.

Source: https://developers.inkfilepicker.com/docs/web/#inkblob-images

Broadloom answered 8/11, 2013 at 2:3 Comment(2)
It would be very nice for the inkfilepicker team to provide a way to make this deterministic. It makes some usage patterns problematic to not be able to do this.Cesaria
is that company still around? The developer link above doesn't work for me.Jaquelin
W
2

It is possible and easy to do with Uploadcare

Here is an example:


Original image:

https://ucarecdn.com/c35d77e8-4b09-4040-ad36-a5b264f17094/CDN.png

enter image description here


Cropped and resized image, in one operation:

https://ucarecdn.com/c35d77e8-4b09-4040-ad36-a5b264f17094/-/crop/570x460/730,70/-/resize/200x150/Resized_CDN.png

enter image description here

Waki answered 3/11, 2014 at 6:52 Comment(1)
FYI: upload care has 100MB storage and 100 uploads. Hopefully this saves some people time.Bolzano

© 2022 - 2024 — McMap. All rights reserved.