Crop image so fits exactly in max width and max height
See original GitHub issue[REQUIRED] Step 2: Extension name
This feature request is for extension: storage-resize-images
What feature would you like to see?
Current behavior as in the documentation:
For example, say that you specify a max width of 200px and a max height of 100px. You upload an image that is 480px wide by 640px high, which means a 0.75 aspect ratio. The final resized image will be 75px wide by 100px high to maintain the aspect ratio while also being at or under both of your maximum specified dimensions.
Using that example parameters, I would like a final resized image of the exact size of max width and max height (200 x 100) instead of 75px x 100px. In that case, in order to maintain the aspect ratio, the image would be cropped.
How would you use it?
Is a common behaviour to show thumbnails (i.e. 56x56) in a list. It’s aesthetically better cropping the image instead of making it fit completely in that size.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (1 by maintainers)
Thanks. It’s just adding a new parameter
fit
at config.ts. And changing function resize at index.ts in line 157, putingfit
instead of'inside'
so it can use that parameter.I would make a pull request with the change, but I don’t get where in the code the user can choose that parameter (the screen that firebase shows in order to configure the extension), and the process of doing everything would take me much longer for this small change, in comparison with you guys.
Hi @magoarcano! Thanks for the feature request. Given the huge array of configuration options that sharp provides, and our desire to keep the parameters for this extension limited to a small set of essential config, we’re not able to add this feature.
However, we have published Cloud Functions sample code here that should be easy to customize to your exact needs. I hope that helps with your use case.