Android Example [B4X] Supabase - Storage Image Transformations


Supabase Storage offers the functionality to transform and resize images dynamically. Any image stored in your buckets can be transformed and optimized for fast delivery.


Download
Every Transform parameter is optional
B4X:
    Dim DownloadFile As Supabase_StorageFile = xSupabase.Storage.DownloadFile("Avatar","test.png")
    DownloadFile.DownloadOptions_TransformQuality(30)
    DownloadFile.DownloadOptions_TransformFormat("origin")
    DownloadFile.DownloadOptions_TransformResize("cover")
    DownloadFile.DownloadOptions_TransformHeight(100)
    DownloadFile.DownloadOptions_TransformWidth(100)
    Wait For (DownloadFile.Execute) Complete (StorageFile As SupabaseStorageFile)
    If StorageFile.Error.Success Then
        Log($"File ${"test.jpg"} successfully downloaded "$)
        ImageView1.SetBitmap(xSupabase.Storage.BytesToImage(StorageFile.FileBody))
    Else
        Log("Error: " & StorageFile.Error.ErrorMessage)
    End If

Modes
You can use different resizing modes to fit your needs, each of them uses a different approach to resize the image:

Use the resize parameter with one of the following values:
  • cover : resizes the image while keeping the aspect ratio to fill a given size and crops projecting parts. (default)
  • contain : resizes the image while keeping the aspect ratio to fit a given size.
  • fill : resizes the image without keeping the aspect ratio.
Example:
B4X:
    Dim DownloadFile As Supabase_StorageFile = xSupabase.Storage.DownloadFile("Avatar","test.png")
    DownloadFile.DownloadOptions_TransformResize("cover")
    Wait For (DownloadFile.Execute) Complete (StorageFile As SupabaseStorageFile)

Limits
  • Width and height must be an integer value between 1-2500.
  • The image size cannot exceed 25MB.
  • The image resolution cannot exceed 50MP.
Supported Image Formats
FormatExtensionSourceResult
PNGpng
JPEGjpg
WebPwebp
AVIFavif
GIFgif
ICOico
SVGsvg
HEICheic
BMPbmp
TIFFtiff

 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…