Image uploads and resizing for trail
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-10-18 16:48:56 -06:00
src build missing viewboxes 2026-10-18 16:48:56 -06:00
.editorconfig port from apricot 2026-10-18 01:30:42 -06:00
.gitignore port from apricot 2026-10-18 01:30:42 -06:00
composer.json bump requirement 2026-10-18 01:52:47 -06:00
LICENSE port from apricot 2026-10-18 01:30:42 -06:00
README.md strip metadata 2026-10-18 15:23:42 -06:00

trail-images

Image uploads and resizing for trail

install

composer require trail/images

Requires gd. Handles jpeg, png, webp, avif, and gif

use

use Trail\Images\Images;

$image = Images::open($request->file('photo'), maxBytes: 10 * 1_048_576);
$image->fit(2400, 2400);
$image->cover(800, 450, focus: [0.3, 0.6]);
$image->crop(0, 0, 400, 400);

$disk->write('photos/cat.webp', $image->encode('webp', quality: 82));

metadata

It strips camera,gps, and editior stuff without changing the actual image/quality/etc. Gif and AVIF just passthrough because animations

$disk->write('photos/cat.jpg', Images::stripMeta($upload->contents()));

svg

use Trail\Images\Svg\Svg;

$clean = Svg::scrub($contents, maxBytes: 100 * 1024);