Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 758
Jeff Sinclair Avatar asked Jun 20 '13 20:06

Jeff Sinclair


2 Answers

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

like image 78
polmiro Avatar answered Sep 28 '22 20:09

polmiro


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

like image 35
David Avsajanishvili Avatar answered Sep 28 '22 20:09

David Avsajanishvili