Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

docs: update image-resizing guide

fenosd8fb46dd6548
diff --git a/apps/docs/components/Navigation/Navigation.constants.ts b/apps/docs/components/Navigation/Navigation.constants.ts
index 29212056fdb..8af16004887 100644
--- a/apps/docs/components/Navigation/Navigation.constants.ts
+++ b/apps/docs/components/Navigation/Navigation.constants.ts
@@ -246,7 +246,7 @@ export const menuItems: NavMenu = {
items: [
{ name: 'Overview', url: '/guides/storage', items: [] },
{ name: 'CDN', url: '/guides/storage-cdn', items: [] },
- { name: 'Image Resizing', url: '/guides/storage-image-resizing', items: [] },
+ { name: 'Image Resizing', url: '/guides/storage/image-resizing', items: [] },
],
},
{
diff --git a/apps/docs/pages/guides/storage-image-resizing.mdx b/apps/docs/pages/guides/storage/storage-image-resizing.mdx
similarity index 51%
rename from apps/docs/pages/guides/storage-image-resizing.mdx
rename to apps/docs/pages/guides/storage/storage-image-resizing.mdx
index dc9cffb9aac..be5219d2ea8 100644
--- a/apps/docs/pages/guides/storage-image-resizing.mdx
+++ b/apps/docs/pages/guides/storage/storage-image-resizing.mdx
@@ -7,17 +7,18 @@ export const meta = {
sidebar_label: 'Image Transformation',
}
-Storage offers the functionality to transform and resize images on the fly.
-Any image stored in your buckets can be transformed and optimized for fast delivery.
+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.
-To get started with image resizing you can pass a `transform` option to the functions you are currently using to interact with your objects.
+<Admonition type="note">
+ Image Resizing is enabled for PRO tiers and above
+</Admonition>
-Image Resizing is enabled for PRO tiers and above
+### Get a public URL for a Transformed image
-### Get a public URL - With transformation options
+You can pass a `transform` option to the functions you are currently using to interact with your objects. This returns the public URL that serves the resized image.
```ts
-storage.from('bucket').getPublicUrl('image.jpg', {
+supabase.storage.from('bucket').getPublicUrl('image.jpg', {
transform: {
width: 500,
height: 600,
@@ -34,11 +35,10 @@ An example URL could look like this:
### Signing URLs - With transformation options
-You can sign the URLs for private buckets in the same way.
-If you are signing an image and you’d like to share a transformed version, you’ll need to provide the transform options to the signing URL function
+To share a transformed image for a fixed amount of time, provide the transform options when you create the signed URL:
```ts
-storage.from('bucket').createSignedUrl('image.jpg', 60000, {
+supabase.storage.from('bucket').createSignedUrl('image.jpg', 60000, {
transform: {
width: 200,
height: 200,
@@ -48,27 +48,12 @@ storage.from('bucket').createSignedUrl('image.jpg', 60000, {
The transformation options are embedded into the token, they cannot be changed once signed.
-### Downloading Images
+## Downloading Images
-We introduced 2 new recommended methods for downloading a file.
-`publicDownload` and `authenticatedDownload`
-
-These new methods allow you to add transformation options and be able to download a modified image instead of the original.
-
-Use `publicDownload` when downloading an object from a **public** bucket.
-Use `authenticatedDownload` when downloading an object from a **private** bucket.
+To download a transformed image, pass the `transform` option to the `download` function
```ts
-// Download from a public bucket
-storage.from('bucket').publicDownload('image.jpg', {
- transform: {
- width: 800,
- height: 300,
- }
-})
-
-// Download from a private bucket
-storage.from('bucket').authenticatedDownload('image.jpg', {
+supabase.storage.from('bucket').download('image.jpg', {
transform: {
width: 800,
height: 300,
@@ -76,22 +61,14 @@ storage.from('bucket').authenticatedDownload('image.jpg', {
})
```
-The existing `download` method is deprecated but will still work.
-We recommend migrating to the new methods `publicDownload` and `authenticatedDownload`
-
-as `download` will be removed in the next major release
-
-
### Transformation options
We currently support a few transformation options focusing on resizing & cropping.
-We have plans to increase the transformation type available in a later release.
+We have plans to increase the transformation types available in a later release.
### Resizing
-You can use `width` and `height` parameters to resize the image to a specific dimension.
-
-Alternatively, you can omit one of the above parameters and the image will be resized and cropped maintaining the aspect ratio.
+You can use `width` and `height` parameters to resize an image to a specific dimension. If only one parameter is specified, the image will be resized and cropped, maintaining the aspect ratio.
### Modes
@@ -105,18 +82,25 @@ Use the `resize` parameter with one of the following values:
- `fill` : resizes the image without keeping the aspect ratio.
-### Limits
+Example:
-Width / Height:
+```ts
+supabase.storage.from('bucket').download('image.jpg', {
+ transform: {
+ width: 800,
+ height: 300,
+ resize: 'contain' // 'cover' | 'fill'
+ }
+})
+```
-- **type**: int
-- **min**: 1
-- **max**: 2500
+### Limits
-The image size cannot exceed 25MB
-The image resolution cannot exceed 50MP
+- 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 Format
+### Supported Image Formats
| Format | Extension | Source | Result |
| -------|-----------|--------|--------|