Skip to content

Solo ImageDecode once. Encode every variant.

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.

Solo Image

Turn an upload into two variants ​

php
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.

Installation ​

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:

sh
composer require "solophp/image:^1.0@rc"

Continue with the getting-started guide.

MIT licensed.