firebase / extensions

Source code for official Firebase extensions
https://firebase.google.com/products/extensions
Apache License 2.0
882 stars 372 forks source link

🐛 [STORAGE_RESIZE_IMAGES] Images resized do NOT maintain aspect ratio #1941

Closed alexdhill closed 5 months ago

alexdhill commented 5 months ago

[READ] Step 1: Are you in the right place?

Issues filed here should be about bugs for a specific extension in this repository. If you have a general question, need help debugging, or fall into some other category use one of these other channels:

[REQUIRED] Step 2: Describe your configuration

[REQUIRED] Step 3: Describe the problem

Steps to reproduce:

  1. Install Resize Images [firebase/storage-resize-images@0.2.2] and set the resize dimensions to "1080x720"
  2. Upload an image to storage that is greater in size (in both dimensions) that the specified resize amount, and with a different aspect ratio: I used a 5000x2500 (WxH) jpeg
Expected result

A resized .webp of size 1080x540

Actual result

A resized .webp of size 1080x720

Extra Comments

I have tried this with an extreme case as well, setting the resize to dimensions to 720x10000 so that an image of size 5000x2500 should be resized to about 720x360, instead it creates a new image of size 720x2500.

pr-Mais commented 5 months ago

Check this issue https://github.com/firebase/extensions/issues/1889#issuecomment-1864603042 Update your configurations field Sharp constructor options for resizing images to have the desired fit, e.g.:

{ "fit": "inside" }
alexdhill commented 5 months ago

This works, is there a way to mark this as needs documentation or?