This feature request is for extension: storage-resize-images
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.
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.
After seen the code I realized it's using the option fit='inside'.
The default option of the resizing library is 'cover'. That's the option I want.
Is it possible to have that option available?
Hey @magoarcano, thanks for the suggestion. I guess that would be considered a feature request considering it would require an additional option. The Firebase Extension's team will take a look at the viability, I'm sure.
Thanks.
It's just adding a new parameter fit at config.ts. And changing function resize at index.ts in line 157, puting fit instead of 'inside' so it can use that parameter.
return sharp(originalFile)
.rotate()
.resize(parseInt(width, 10), parseInt(height, 10), { fit: "inside" })
.toFile(resizedFile);
}
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.
This would be a helpful configuration for me as well. Most thumbnails I use would be using the 'cover' option and not the fit option. "Fit" results in very low res thumbnails when you have a large range in aspect ratio's. E.g. if you fit to 400x400 and you have a landscape image of let's say 1200x600, this will be resized to 400x200, where 800x400 would be preferable.
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.
Most helpful comment
Thanks.
It's just adding a new parameter
fitat config.ts. And changing function resize at index.ts in line 157, putingfitinstead 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.