Looking to hire Laravel developers? Try LaraJobs

laravel-imagepresets maintained by fomvasss

Description
Image presets (on-the-fly resize/convert) for Laravel via League Glide
Author
Last update
2026/10/07 18:50 (dev-master)
License
Links
Downloads
481

Comments
comments powered by Disqus

Laravel Image Presets

License Latest Stable Version Total Downloads

On-the-fly image resizing, cropping and format conversion for Laravel, powered by League Glide. One endpoint takes the source and the transformation in the query string, generates the image on the first request, stores it on a filesystem disk and serves the stored file with long-lived cache headers afterwards.

Українською

  • One auto-registered endpoint — no session, no CSRF, throttled
  • Allowlists for sizes, qualities, fits and formats; named presets in config
  • Any disk — local, S3, GCS, FTP; optional redirect to a presigned URL
  • Local and remote sources with SSRF and image-bomb checks
  • WebP, AVIF, JPG, PNG, GIF output; GD or Imagick; HEIC input with Imagick
  • SVG — sanitized passthrough or rasterization
  • Signed URLs and trusted bypass for backend-generated URLs
  • imagepresets:clear and imagepresets:verify for cache maintenance
  • imagepreset_url() helper, Imagepreset facade, @imagepreset Blade directive

Requirements

  • PHP ^8.1
  • Laravel 10 | 11 | 12 | 13
  • league/glide ^2.0 | ^3.0, ext-gd or ext-imagick

Installation

composer require fomvasss/laravel-imagepresets

php artisan vendor:publish --tag=imagepresets-config
IMAGEPRESET_PATH=imagepresets

Set IMAGEPRESET_PATH. With the default empty path generated files land in the root of the public disk, and imagepresets:clear / imagepresets:verify refuse to run (before 1.19.1 clear deleted the whole disk).

Quick start

// config/imagepresets.php
'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="">
<img src="/imagepreset?src=images/photo.jpg&w=600&fm=webp" alt="">

Sizes outside the allowlists (allowed_widths, allowed_sizes, …) return 404 — configure them or use presets.

Documentation

Online: https://fomvasss.github.io/laravel-imagepresets/ — the same pages as in docs/.

Testing

composer test

License

MIT — see LICENSE.

Support

If this package is useful to you, consider supporting its development:

Monobank Ko-Fi USDT TRC20

USDT TRC20: THLgp6DxiAtbNHvgnKV56vk1L38UuUagKf