crop

The crop transformation extracts a rectangular region from an image. Specify dimensions and position (x, y) to crop, or use gravity parameters (north, south, east, west, center) for intelligent cropping. Perfect for creating consistent thumbnail sizes or extracting specific portions of images.

Serving Content via CDN

The Media API is a CDN-based service that serves transformed images via GET requests. When you request a transformed image URL, the transformation is applied dynamically on the first request and then cached for subsequent requests.

URL Pattern

https://media.vyso.io/crop:width=W:height=H:x=X:y=Y/ASSET_ID.jpg

Examples

Crop Center Square (300x300)

curl -i GET https://media.vyso.io/crop:width=300:height=300/ASSET_ID.jpg

Crop from Top-Left (100x100)

curl -i GET https://media.vyso.io/crop:width=100:height=100:x=0:y=0/ASSET_ID.jpg

Crop Specific Region

curl -i GET https://media.vyso.io/crop:width=200:height=150:x=50:y=50/ASSET_ID.jpg

Crop Landscape Portion

curl -i GET https://media.vyso.io/crop:width=800:height=400:gravity=center/ASSET_ID.jpg

Crop Portrait Portion

curl -i GET https://media.vyso.io/crop:width=400:height=600:gravity=north/ASSET_ID.jpg

On the first request, you'll receive a X-Cache: MISS header while the transformation is applied and cached. Subsequent requests will return X-Cache: HIT.

Parameters

widthREQUIRED

Width of the crop area in pixels. Positive integer (e.g., 300).

heightREQUIRED

Height of the crop area in pixels. Positive integer (e.g., 300).

xOPTIONAL

X coordinate (horizontal position) of the crop starting point. Default: center. Positive integer (e.g., 50).

yOPTIONAL

Y coordinate (vertical position) of the crop starting point. Default: center. Positive integer (e.g., 50).

gravityOPTIONAL

Gravity for intelligent positioning. Accepted values:

  • center (default) - Crop from center
  • north - Crop from top
  • south - Crop from bottom
  • east - Crop from right
  • west - Crop from left

Response

The API returns the cropped portion of the image with the specified dimensions. The response format depends on the format of the asset stored in the Vyso asset cloud.

Content-Type: Determined by the stored asset format (e.g., image/jpeg, image/png)