[B4X] Supabase - The Open Source Firebase alternative
Supabase is an open source Firebase alternative. It provides all the backend services you need to build a product. Supabase uses Postgres database with real-time capabilities. Basically, supabase provides an interface to manage postgres database that you can use to create table and insert, edit...
www.b4x.com
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.
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.
Format | Extension | Source | Result |
---|---|---|---|
PNG | png | ||
JPEG | jpg | ||
WebP | webp | ||
AVIF | avif | ||
GIF | gif | ||
ICO | ico | ||
SVG | svg | ||
HEIC | heic | ||
BMP | bmp | ||
TIFF | tiff |