Picture quality still reducing too much even after configuring resize images extension on firebase

760 Views Asked by At

I have an image upload function on my application that is using firebase as a backend. I've enabled the Resize Images extension, but the quality was too low on jpeg and webp files. In order to counteract this I added some Sharp Output Options as follows:

{"jpeg": {"quality": 100}, "webp": {"quality": 100, "lossless": true}}

There's no real information out there about what the potential values are for these fields.

You can see their suggested formatting for the Sharp Output Options here:

Sharp Output Options

That's all the info I can find.

However, the image quality did not change after this config. Both before and after setting this configuration the image sizes were identical.

How can I properly set this configuration and increase the quality of the compressed images?

2

There are 2 best solutions below

2
On

I have the same problem.

When I tried to convert .jpg to .jpeg and set the option to {"quality": 5}, a clear deterioration was confirmed.

And the following three had the same degree of deterioration.

  • No options
  • {"Quality": 100}
  • No conversion

It seems that sharp in the extension has already been resized for minimal degradation.

Looking at the source file, sharp's outputOptions were only applied during the conversion.

I thought the cause was elsewhere and decided to finish my investigation into this extension.

However, I'm worried about rotate, which seems to be meaningless ...

SourceFile https://github.com/firebase/extensions/blob/8efd4e18afdb62218e1422deee1d60c89df9ebb9/storage-resize-images/functions/src/resize-image.ts#L19

Sharp https://sharp.pixelplumbing.com/api-output#jpeg

0
On

My solution was to increase the pixel size of the images. Instead of targeting 400x400, I chose 800x800. The file size was slightly larger, but only about an extra 7kb for an image that was originally 1.3mb. After firebase's compression, my 800x800 image was around 22kb, but with much better resolution than the 15kb 400x400 image I was trying at first.