Search by

fomvasss / laravel-imagepresets

fomvasss

Image presets (on-the-fly resize/convert) for Laravel via League Glide

Package info

github.com/fomvasss/laravel-imagepresets

pkg:composer/fomvasss/laravel-imagepresets

Statistics

Installs: 448

Dependents: 0

Suggesters: 1

Stars: 10

Open Issues: 0

1.19.0 2026-08-16 09:39 UTC

README

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 deletes 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