Photos the right way up
All eight EXIF orientations are applied on decoding, mirrored ones included, from JPEG, PNG and WebP metadata. Width and height describe the picture as people see it.
Immutable GD images for PHP. EXIF orientation, bounded resizing, JPEG, PNG and WebP encoding, and optimization that keeps a result only when it is smaller.
use Solo\Image\Format;
use Solo\Image\Image;
$image = Image::fromBytes($bytes);
$thumbnail = $image->resize(width: 320)->encode(Format::Webp);
$preview = $image->resize(width: 1200, height: 900)->encode(Format::Jpeg, quality: 85);
$storage->put("photos/{$id}-thumb.{$thumbnail->extension()}", $thumbnail->bytes);
$storage->put("photos/{$id}.{$preview->extension()}", $preview->bytes);fromBytes() detects the format from the contents, checks the limits and turns the photo the right way up. Each variant has its own pixels, and $image stays as it was decoded. Read the getting-started guide for optimization, limits and errors.
PHP 8.3+ is required, with the gd and exif extensions. GD must be built with support for the formats you use: JPEG, PNG and WebP.
Version 1.0 is a release candidate, so Composer needs to be told that a pre-release is acceptable:
composer require "solophp/image:^1.0@rc"Continue with the getting-started guide.