spatie

spatie/image-optimizer

PHP MIT Dev Tools

Easily optimize images using PHP

2.9k stars
224 forks
recent
GitHub

2.9k

Stars

224

Forks

0

Open issues

30

Contributors

1.10.0 29 Jun 2026

AI Analysis

This PHP package optimizes images (PNG, JPG, WEBP, AVIF, SVG, GIF) by orchestrating a chain of external optimization binaries. It automatically detects which tools are installed and uses them to reduce file size. It serves developers and PHP applications that need to minimize image assets, particularly useful in web projects, Laravel applications, and WordPress installations.

Dev Tools Library Discovery value: 4/10
Documentation 9/10
Activity 9/10
Community 8/10
Code quality 7/10

Inferred from signals mentioned in the README (tests, CI, type safety) — not a review of the actual code.

Overall score 8/10

AI's overall editorial judgment — not an average of the bars above, can weigh other factors too.

image-optimization php-library performance-tuning asset-pipeline multi-format-support
Actively maintained Well documented MIT licensed Popular Beginner friendly Production ready
Deep Analysis · Based on README and public signals
4d ago

PHP wrapper for image optimization binaries—narrow tooling layer, widely adopted in Laravel ecosystem

spatie/image-optimizer is a PHP library that wraps system-level image optimization tools (jpegoptim, optipng, pngquant, svgo, gifsicle, cwebp, avifenc) into a simple procedural API. It auto-detects installed binaries and chains them for JPEG, PNG, WEBP, AVIF, SVG, and GIF optimization. Primary adoption is within Laravel projects via the companion laravel-image-optimizer package; secondary use in WordPress, SilverStripe, and standalone PHP applications. Maintained actively by Spatie, a Belgian agency known for pragmatic, narrowly-scoped open source libraries.

Origin

Created July 2017 as a Spatie utility, predating mainstream WEBP and AVIF adoption in web development. Evolved from internal tooling into a published package; design philosophy reflects PHP ecosystem patterns (dependency injection, chainable configuration, minimal opinions). Gained traction as Laravel-adjacent infrastructure rather than as a stand-alone competitor to desktop optimizers like ImageOptim.

Growth

Stars accumulated steadily (2,873 total) but growth rate is modest (~1 star/week as of June 2026). Traction correlates with Laravel adoption curve rather than organic library discovery. Companion laravel-image-optimizer package (1,306 stars) indicates majority use case is Laravel form-processing and asset pipelines. Mid-2020s additions of AVIF and WEBP support kept it current with web standards, but growth did not accelerate post-update—suggests adoption is stable rather than expanding into new use cases.

In production

Strong indirect evidence: companion laravel-image-optimizer package has 1,306 stars and explicit use-case documentation. README cites live installations in WordPress (WP CLI command), SilverStripe (module), and Packagist download metrics available but not quoted in excerpt. Adoption appears concentrated in PHP web frameworks rather than distributed across general use. Adoption not globally verified but highly likely in Laravel ecosystem; adoption outside Laravel not clearly documented.

Code analysis
Architecture

Appears to follow object-oriented composition: OptimizerChainFactory instantiates a chain of optimizer objects, each wrapping a system binary. README indicates automatic detection of installed tools; likely implements conditional optimizer registration. Based on README, no optimization passes through PHP itself—all work delegated to system binaries. Design is a thin procedural wrapper, not an image processing library.

Tests

Not documented in README. GitHub badge for 'Tests' workflow present but pass/fail status not shown in excerpt.

Maintenance

Last push 2026-06-29 (9 days before evaluation date). Active CI/CD (Tests badge visible). Repository created 2017, so 9+ years old—indicates stable, mature project. Slow weekly star gain and lack of recent feature announcements suggest maintenance is reactive (responding to ecosystem changes) rather than aggressive feature development. Consistent maintenance rhythm typical of Spatie's approach to 'good enough' utilities.

Honest verdict

ADOPT IF: you are building PHP/Laravel projects requiring server-side image optimization in development or production; you want a dependency-injection-friendly wrapper around system binaries; your hosting environment has flexibility to install optimization CLI tools. AVOID IF: you need image manipulation beyond lossless/lossy compression (resizing, watermarking, format conversion handled by separate tools); you require guaranteed availability of all optimization binaries (package degrades gracefully but quality depends on which tools are present); you prefer pure-PHP solutions without system dependencies; your platform (e.g., serverless) cannot invoke external binaries. MONITOR IF: considering adoption in non-Laravel PHP frameworks—wrapper quality is good but ecosystem integration is Laravel-first, so cost of bespoke integration should be evaluated.

Independent dimensions

Mainstream potential

3/10

Technical importance

5/10

Adoption evidence

7/10

Risks
  • System binary dependency: optimization quality is only as good as installed tools. Missing binaries silently degrade results; no built-in fallback or warning mechanism documented.
  • Maintenance burden of tracking optimization CLI tool versions and deprecations (e.g., SVGO 1 vs. 2 API drift)—kept in sync via README but requires reactive updates.
  • Narrow scope and lack of growth suggest limited resources for handling emerging formats or addressing edge cases outside core Laravel use case.
  • SVG-specific caveat in README (SVGO can break output) indicates potential data loss risk for certain input types—users must understand and test carefully.
  • No direct evidence of adoption outside PHP/Laravel ecosystem; portability to other languages unclear.
Prediction

Will remain a stable, maintenance-mode utility for Laravel and adjacent PHP frameworks. Unlikely to gain significantly broader adoption outside web development or to spawn competitors in PHP space. May add support for emerging formats (JPEG-XL, HEIC) reactively if ecosystem demands. Will gradually shift focus toward container/orchestration compatibility (Docker best practices for binary installation) as deployment patterns evolve.

0 found this helpful

Newsletter

Get analyses like this every Monday

Free weekly digest of the most interesting open-source discoveries.

Languages

PHP
99.6%
JavaScript
0.4%

Information

Language
PHP
License
MIT
Last updated
2w ago
Created
110mo ago
Analyzed with
anthropic/claude-haiku-4-5

Stars over time

Loading…

Contributors over time

Top 100 contributors only — repos with more will plateau at 100.

Loading…

Open issues

No open issues — clean slate.

Open pull requests

No open pull requests.

Similar repos

spatie

spatie/laravel-image-optimizer

A Laravel-specific wrapper for the spatie/image-optimizer package that...

1.3k PHP Web Dev
spatie

spatie/image

Spatie Image is a PHP library for image manipulation with a fluent, expressive...

1.4k PHP Media
spatie

spatie/pdf-to-image

This PHP package converts PDF files to images (JPG, PNG, WebP, WEBP) using...

1.4k PHP Dev Tools
toy

toy/image_optim

image_optim is a Ruby gem and command-line tool that compresses JPEG, PNG, GIF,...

1.6k Ruby Dev Tools
ImageOptim

ImageOptim/ImageOptim

ImageOptim is a native macOS GUI that wraps multiple lossless image...

9.9k HTML Dev Tools
vs. alternatives
ImageOptim (9,885 stars, macOS desktop app)

Entirely different category (GUI desktop vs. PHP library). Solves human-facing optimization; spatie/image-optimizer solves server-side automation. Not competitors.

toy/image_optim (1,551 stars, Ruby)

Functional equivalent in Ruby ecosystem. Similar star count suggests comparable adoption within respective language communities. PHP version likely leads Laravel; Ruby version likely leads Rails.

spatie/image (1,362 stars, PHP)

Sister package in same organization. image-optimizer focuses on CLI binary wrapping; spatie/image likely handles PHP-level image manipulation. Complementary rather than competitive.

spatie/laravel-image-optimizer (1,306 stars, PHP)

Framework-specific wrapper around this package. Higher star count relative to base package suggests users adopt through Laravel integration rather than standalone library.

System binaries (jpegoptim, optipng, etc.) directly

spatie/image-optimizer eliminates need to shell-exec binaries manually and auto-detects available tools. Reduces scaffolding boilerplate in PHP projects.