Image uploads and resizing for trail
- PHP 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| src | ||
| .editorconfig | ||
| .gitignore | ||
| composer.json | ||
| LICENSE | ||
| README.md | ||
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);