firebase / extensions

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

🐛 [storage-resize-images] Override sharp output parameters with customized image metadata #2080

Open TangrisJones opened 2 months ago

TangrisJones commented 2 months ago

Extension name

This feature request is for extension: storage-resize-images

What feature would you like to see?

It would be super useful to be able to override certain config parameters on the fly via image metadata. For example, suppose we had some sort of structure like the following to override the "sharp output options" config in an image's metadata that is going to be resized

{
   resizeImageConfig: {
      sharpOutputOptions: {
         png: {
            quality: 50,
            compressionLevel: 9
         }
      }
   }
}

The extension could then override the global config levels according to this metadata on the fly, effectively customizing the compression on a per image basis.

How would you use it?

I would love this feature, because currently I have different kinds of images that I'm resizing. Some are fine for lossy compression, but one kind of image I can't use lossy compression on it, so I will have to just stick with lossless only. I'd love to apply this metadata to customize the compression for those images where lossy isint suitable (i.e. setting quality=100 when globally, quality=75). This will effectively override the "sharp output options" config option on an image-by-image basis, so that we are not stuck with one global config only.

Currently, the only way I know how to do something like this is to either install a second extension, or build it myself.

I think this feature could really help extend the extensions functionality. Would love to hear any thoughts on it!