Laravel Image Presets
On-the-fly image resizing, cropping and format conversion for Laravel, powered by League Glide.
The package registers one GET endpoint (/imagepreset by default). A request names a source image and the transformation in the query string; the first request generates the image and stores it on a filesystem disk, every next request serves the stored file with long-lived cache headers.
- One endpoint, no setup — the route is registered automatically, without session or CSRF
- Allowlists — widths, heights, size pairs, qualities, fits and formats a client may request, so the endpoint can’t be used to fill the disk
- Named presets —
thumb,og_imageand the like defined once in config - Any disk — local or remote (S3, GCS, FTP); optional redirect to a presigned URL
- Local and remote sources — remote hosts from an allowlist, with SSRF and image-bomb checks
- SVG — sanitized passthrough, optional rasterization with Imagick
- Signed URLs and trusted bypass — accept only URLs generated by the backend
- Cache maintenance —
imagepresets:clear,imagepresets:verifyfor truncated or damaged files - Helper, facade and Blade directive —
imagepreset_url(),Imagepreset::url(),@imagepreset()
Quick example
Section titled “Quick example”'presets' => [ 'thumb' => ['w' => 300, 'h' => 200, 'fit' => 'crop', 'fm' => 'webp', 'q' => 80],],<img src="@imagepreset('images/photo.jpg', 'thumb')" alt=""><img src="{{ imagepreset_url('images/photo.jpg', ['w' => 600, 'fm' => 'webp']) }}" alt="">http://example.com/imagepreset?preset=thumb&src=images%2Fphoto.jpghttp://example.com/imagepreset?fm=webp&src=images%2Fphoto.jpg&w=600Contents
Section titled “Contents”Getting started
Usage
- Generating URLs
- Transformations
- Named presets
- Allowlists & audit log
- Image sources
- Storage disks
- Drivers & formats
- SVG
- HTTP caching & CDN
- Signed URLs
- Trusted bypass
- Cache maintenance
- Security
Reference