Skip to content

Transformations

Transformations are Glide parameters passed in the query string. Only the parameters below reach Glide; anything else is ignored (but still becomes part of the cache key). The full table with validation rules — Query parameters.

/imagepreset?src=photo.jpg&w=600 # width only
/imagepreset?src=photo.jpg&h=400 # height only
/imagepreset?src=photo.jpg&w=600&h=400&fit=crop
  • w only — must be in allowed_widths; h only — in allowed_heights; both — the pair must be in allowed_sizes. See Allowlists.
  • Without fit the package uses default_fit_both (fill) when both sizes are given and default_fit_one (max) when one is.
  • fit without w or h in the request is rejected (404), even when a preset supplies the size.
  • Without w and h the image keeps its size and is only re-encoded.
fitResult
containScaled to fit inside w×h, aspect ratio kept, may upscale. Output can be smaller than the box on one side
maxLike contain, but never upscales
fillLike max (never upscales), then padded to exactly w×h
fill-maxLike contain (upscales if needed), then padded to exactly w×h
cropScaled to cover w×h and cropped from the centre — exactly w×h, nothing padded
stretchResized to exactly w×h, aspect ratio ignored

Padding is transparent; set the colour with bg (e.g. bg=ffffff for JPG output). Use fill-max when the whole image must be visible at an exact size (og:image, product feeds), crop when trimming the edges is acceptable.

Glide also understands crop positions (crop-top, crop-bottom-left, …) and focal points (crop-25-75). They work once added to allowed_fits.

/imagepreset?src=photo.jpg&w=600&fm=jpg&q=90
  • q — encoder quality, must be in allowed_qualities. Default — quality (80). Ignored for png and gif.
  • fm — output format, must be in allowed_formats. Default — format (webp). pjpg (progressive JPEG) is stored with the .jpg extension. Format support depends on the driver, see Drivers & formats.
ParameterExampleDescription
blurblur=10Blur, 0–blur_max (Glide itself accepts up to 100)
sharpsharp=15Sharpen, 0–sharp_max (Glide itself accepts up to 100)
oror=autoOrientation: auto reads EXIF (photos from phones), or 0/90/180/270
cropcrop=200,200,10,10Cut a width,height,x,y rectangle from the source before resizing
bgbg=ffffffBackground colour, 3–8 hex digits without #. Fills transparent areas and fit padding

These parameters are not limited by the size allowlists and work with or without w/h.

imagepreset_url('logo.png', ['w' => 400, 'fm' => 'jpg', 'bg' => 'ffffff']);

Without bg the transparent areas get the driver’s default colour.