supabase / supabase-flutter

Flutter integration for Supabase. This package makes it simple for developers to build secure and scalable products.
https://supabase.com/
MIT License
662 stars 155 forks source link

Storage: Image quality transformation is respected for createSignedUrl() but not for download() #834

Open pdurasie opened 4 months ago

pdurasie commented 4 months ago

Describe the bug For supabase storage, when you use transform params together with quality parameter in the download method, the returned image will respect the height and width params but ignore the quality. In other words, no matter whether you pass in quality: 20 or quality: 100, the returned image will be the same.

Additionally, the image will be returned in PNG even though WebP would be expected, as I'm working with Flutter Web (Chrome), but this might be a separate issue with Automatic image optimization.

To Reproduce Steps to reproduce the behavior:

  1. Upload a PNG image to a bucket
  2. Run this in Flutter Web (Chrome) and check the file size, dimensions and image quality in Chrome DevTools
    await supabase.storage.from('my-bucket').download(
          'my_img.png',
          transform: const TransformOptions(
            height: 840,
            width: 480,
            quality: 100,
          ),
        );
  3. Clear cache and run this in Flutter Web (Chrome) and check the file size, dimensions and image quality in Chrome DevTools
    await supabase.storage.from('my-bucket').download(
          'my_img.png',
          transform: const TransformOptions(
            height: 840,
            width: 480,
            quality: 20,
          ),
        );

You will see that the downloaded images in 2. and 3. will be PNG, identical file size, of dimensions 480x840 and 100% quality.

Expected behavior The downloaded images should differ in file size and quality (and be WebP).

Version (please complete the following information): ├── supabase_flutter 2.3.2 │ ├── supabase 2.0.7 │ │ ├── functions_client 2.0.0 │ │ ├── gotrue 2.5.0 │ │ ├── postgrest 2.1.0 │ │ ├── realtime_client 2.0.0 │ │ ├── storage_client 2.0.1

Additional context Using the same parameters to createSignedUrl and then pasting that URL into Chrome does affect the returned image as expected (different quality and WebP).

I have not tested mobile.

I have not tested other image formats but PNG.