URL-Based Image Transformation Reference

This reference provides URL-based image transformation parameters for images served by the Media API. You can transform images by appending transformation parameters to Wix media URLs, allowing you to resize, crop, and change formats without additional processing.

Note: For programmatic image manipulation in JavaScript apps, you can use the Image-Kit package instead of URL transformations. The package provides the same functionality with a JavaScript API and additional features like batch processing.

Before you begin

It's important to note the following points before starting to code:

  • Image transformations only work with Wix-hosted media URLs, static.wixstatic.com.
  • URL-based transformations only work for public media files.
  • The backend applies transformations and caches them for performance.
  • Invalid parameters return HTTP 400 errors with descriptive messages.

URL transformation methods

You can transform images using 3 methods. Each method serves different use cases depending on your layout requirements.

When to use each method

MethodUse caseBehavior
FitPreserve entire image in boundsScales image to fit dimensions, adds padding if needed
FillFill container completelyScales and crops image to fill exact dimensions
CropExtract specific image regionCuts specified rectangular area from original image

Transformation parameters

Fit transformation

Scales the image to fit in specified dimensions while preserving the original aspect ratio.

URL format: "{{your-URL}}/v1/fit/w_{{width}},h_{{height}}/file.{{fileExtension}}"

Parameters:

  • width: Target width in pixels, 1-5000.
  • height: Target height in pixels, 1-5000.
  • fileExtension: Output format. For example, jpg, png, webp, gif.

Example:

"https://static.wixstatic.com/media/11062b_58a1e9635ec6423f98b2f3407ccea943~mv2.jpeg/v1/fit/w_640,h_640/file.jpg"

Note: The fit transformation scales the image to the requested dimensions while keeping the original aspect ratio. The resulting image may be smaller than the requested dimensions if the aspect ratios differ. For example, a 1000x500 image requested at 1000x250 returns a 500x250 image. Also, images aren't scaled up beyond their original size, attempts to do so returns the original image.

Fill transformation

Scales the image to completely fill specified dimensions while preserving the original aspect ratio. When aspect ratios differ, the system crops the image to fit.

URL format: "{{your-URL}}/v1/fill/w_{{width}},h_{{height}}/file.{{fileExtension}}"

Parameters:

  • width: Target width in pixels, 1-5000.
  • height: Target height in pixels, 1-5000.
  • fileExtension: Output format. For example, jpg, png, webp, gif.

Example:

"https://static.wixstatic.com/media/11062b_58a1e9635ec6423f98b2f3407ccea943~mv2.jpeg/v1/fill/w_640,h_640/file.jpg"

Note: When the target dimensions have a different aspect ratio than the source image, the system crops the image from the center to fill the specified dimensions exactly.

Crop transformation

Extracts a rectangular region from the original image starting at specified coordinates. The coordinate system uses the top-left corner as origin (0,0), with x increasing rightward and y increasing downward.

URL format: "{{your-URL}}/v1/crop/x_{{xStartingPosition}},y_{{yStartingPosition}},w_{{width}},h_{{height}}/file.{{fileExtension}}"

Parameters:

  • xStartingPosition: Left edge coordinate in pixels, from 0 to image width.
  • yStartingPosition: Top edge coordinate in pixels, from 0 to image height.
  • width: Target width in pixels, 1-5000.
  • height: Target height in pixels, 1-5000.
  • fileExtension: Output format. For example, jpg, png, webp, gif.

Example:

"https://static.wixstatic.com/media/11062b_58a1e9635ec6423f98b2f3407ccea943~mv2.jpeg/v1/crop/x_1000,y_100,w_1500,h_1500/file.webp"

Note: All coordinate and dimension parameters must be in the image bounds. If any parameter exceeds the original image dimensions, the request returns an HTTP 400 error.

Supported file formats

ExtensionFormatUse case
jpgJPEGPhotographs, images with many colors
pngPNGImages with transparency, simple graphics
webpWebPModern format with better compression
gifGIFSimple animations, limited color images

Error responses

Invalid transformation requests return HTTP 400 status with error details:

Error conditionHTTP statusResponse
Invalid dimensions400{"error": "Invalid dimensions: width and height must be 1-5000"}
Crop out of bounds400{"error": "Crop parameters exceed image boundaries"}
Unsupported format400{"error": "Unsupported file format: {format}"}
Invalid URL structure400{"error": "Invalid media URL format"}
Did this help?