Skip to content
This repository has been archived by the owner on May 12, 2023. It is now read-only.

feat: format option for webp support #60

Merged
merged 7 commits into from
Apr 14, 2023
Merged

feat: format option for webp support #60

merged 7 commits into from
Apr 14, 2023

Conversation

dshukertjr
Copy link
Member

@dshukertjr dshukertjr commented Apr 13, 2023

What kind of change does this PR introduce?

Dart implementation of supabase/storage-js#142

This PR is branched out from #59 (comment)

What is the new behavior?

Introduced a format option to request the image in a different format.
Currently, the only value allowed is origin which will force the image to be returned with its original format.
If not provided we will automatically optimise the image using webp

Additional context

      final bytesArray = await storage.from(privateBucketName).download(
            uploadPath,
            transform: TransformOptions(
              width: 200,
              height: 200,
              format: RequestImageFormat.origin,
            ),
          );

@dshukertjr dshukertjr marked this pull request as draft April 13, 2023 05:45
@dshukertjr dshukertjr marked this pull request as ready for review April 13, 2023 06:02
Copy link
Contributor

@Vinzent03 Vinzent03 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that mean, when uploading a jpg file and downloading it again it gets converted to webp unless I pass origin to the download?

@dshukertjr
Copy link
Member Author

@Vinzent03
Only if the client supports webp.

So the idea is that storage-api will look at the Accept headers of the request for any download request, and it will return the image in "the most efficient format" within it, which I think right now we only have webp support. If webp is not supported by the client, it will not return the image in webp format!

Also, all of these dynamic image conversion features are only supported in Supabase projects with pro tier and above.

@dshukertjr dshukertjr merged commit 0fdda84 into main Apr 14, 2023
@dshukertjr dshukertjr deleted the feat/webp branch April 14, 2023 12:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants