- Media API
- Transformations
- Resize
- crop
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.jpgExamples
Crop Center Square (300x300)
curl -i GET https://media.vyso.io/crop:width=300:height=300/ASSET_ID.jpgCrop from Top-Left (100x100)
curl -i GET https://media.vyso.io/crop:width=100:height=100:x=0:y=0/ASSET_ID.jpgCrop Specific Region
curl -i GET https://media.vyso.io/crop:width=200:height=150:x=50:y=50/ASSET_ID.jpgCrop Landscape Portion
curl -i GET https://media.vyso.io/crop:width=800:height=400:gravity=center/ASSET_ID.jpgCrop Portrait Portion
curl -i GET https://media.vyso.io/crop:width=400:height=600:gravity=north/ASSET_ID.jpgOn 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
widthREQUIREDWidth of the crop area in pixels. Positive integer (e.g., 300).
heightREQUIREDHeight of the crop area in pixels. Positive integer (e.g., 300).
xOPTIONALX coordinate (horizontal position) of the crop starting point. Default: center. Positive integer (e.g., 50).
yOPTIONALY coordinate (vertical position) of the crop starting point. Default: center. Positive integer (e.g., 50).
gravityOPTIONALGravity for intelligent positioning. Accepted values:
center(default) - Crop from centernorth- Crop from topsouth- Crop from bottomeast- Crop from rightwest- 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)