Search by

trail / images

dodgycoffee

Image uploads and resizing for trail

0.4.2 2026-10-18 22:48 UTC

This package is auto-updated.

Last update: 2026-10-19 09:05:59 UTC


README

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);