trim

Remove pixels from the edge of an image.

The trim parameter removes pixels from the edge of an image by pixel or percentage value. This can be useful for removing whitespace and borders that appear on a source image.

Syntax

trim={top},{right},{bottom},{left}

Sub-parameters

ParamUnits
topPixels or Percentage
rightPixels or Percentage
bottomPixels or Percentage
leftPixels or Percentage

Notes

  1. Values can be specified using CSS style shorthand values. (See CSS Margin or CSS Padding for more examples).
  2. CSS shorthand allows for all edges to be specified in one property.
  3. Any fractional pixel measurements will be rounded to the nearest whole pixel.

Examples

Click the links to view the transformed image using a demo Fastly IO service.

Example usageDescription
?trim=25,50,75,100Trim top edge 25px, right edge 50px, bottom edge 75px and left edge 100px
?trim=25,50,75Trim top edge 25px, right and left edge 50px, bottom edge 75px
?trim=25,50Trim top and bottom edge 25px, right and left edge 50px
?trim=0.25Trim all edges by 25%

User contributed notes

BETA

Do you see an error in this page? Do you have an interesting use case, example or edge case people should know about? Share your knowledge and help people who are reading this page! (Comments are moderated; for support, please contact Fastly support)