mathiasgrimm / glimpse-php
PHP SDK for glimpseimg.com: convert, optimize, resize, thumbnail and analyze images.
Requires
- php: ^8.2
- guzzlehttp/guzzle: ^7.8
- illuminate/http: ^10.0|^11.0|^12.0|^13.0
Requires (Dev)
- laravel/pint: ^1.29
- pestphp/pest: ^3.8.4|^4.1.2
- phpstan/phpstan: ^2.2
Suggests
- ext-gd: Far tighter analyze size estimates when Imagick is unavailable (SampleProbe)
- ext-imagick: Far tighter analyze size estimates, plus AVIF and CMYK support (SampleProbe)
This package is auto-updated.
Last update: 2026-07-22 13:33:31 UTC
README
Ship smaller images. Skip the toolchain.
Convert, optimize, resize, thumbnail and analyze images from any PHP application.
The official PHP SDK for glimpseimg.com, the image API for developers.
Shipping images means wrangling ImageMagick, libvips, mozjpeg, cwebp and avifenc: compiled binaries that differ between your laptop, your teammate's laptop, and production. glimpse-php replaces all of them with one method call, with zero binary dependencies. The heavy lifting happens on the Glimpse API: stateless, nothing stored, your bytes never linger. You require a single package and go:
composer require mathiasgrimm/glimpse-php
use MathiasGrimm\GlimpsePhp\Client; use MathiasGrimm\GlimpsePhp\ImageFormat; use Illuminate\Http\Client\Factory; $glimpse = new Client(new Factory, 'your-api-token'); $avif = $glimpse->convert(file_get_contents('photo.jpg'), ImageFormat::Avif); file_put_contents('photo.avif', $avif->bytes);
That is the whole integration: no extensions to compile, no binaries to pin, no queue of shell-outs to babysit. Every method returns typed, immutable results.
Documentation
The full documentation lives at glimpseimg.com/docs/sdk:
- Installation: requirements and optional extensions.
- Authentication: building the client and verifying tokens.
- Methods: every method and the typed objects it returns.
- Laravel: container wiring and
Http::fake()in tests. - Errors: the exception hierarchy.
Upgrading from v1? The upgrade guide covers the move from array returns to typed objects.
Development
composer install composer test # Pint (check), PHPStan, and the Pest suite
Releasing
make release VERSION=vX.Y.Z
Runs the test suite, tags VERSION, pushes the tag, and creates the GitHub release. Packagist picks the new tag up through the GitHub webhook.
License
glimpse-php is open-source software licensed under the MIT license.
Prefer the terminal? glimpse-cli is the first-party CLI: the same API from your shell and CI, no PHP code required.
Grab a free API key at glimpseimg.com (Settings → API Tokens).
