# spatie/image-optimizer

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/spatie-image-optimizer).**

2,873 stars · 223 forks · PHP · MIT

## Links

- GitHub: https://github.com/spatie/image-optimizer
- Homepage: https://freek.dev/797-easily-optimize-images-using-php-and-some-binaries
- awesome-repositories: https://awesome-repositories.com/repository/spatie-image-optimizer.md

## Topics

`gif` `image` `jpeg` `optimizer` `performance` `php` `png`

## Description

This project is a PHP library designed to automate image compression by orchestrating external command-line binaries. It provides a unified interface for managing the execution, configuration, and error handling of system-level tools, allowing developers to integrate image optimization directly into server-side application workflows or automated build pipelines.

The library distinguishes itself through its ability to chain multiple independent processing tools into a single, sequential workflow. By defining custom optimization sequences and configuring specific command-line arguments, users can control how images are transformed. The system supports interface-based extensibility, enabling the integration of custom optimization logic alongside standard binary wrappers.

The toolkit includes comprehensive management for external process lifecycles, including strict timeout enforcement and detailed logging of execution states. It provides flexible error handling mechanisms that allow developers to define how the system should respond when specific optimization tasks fail or exceed time limits. The package is available as a standard PHP library for integration into existing development environments.

## Tags

### Web Development

- [Image Optimization Tools](https://awesome-repositories.com/f/web-development/image-optimization-tools.md) — Reduces image file sizes by chaining system-level processing tools for web delivery. ([source](https://github.com/spatie/image-optimizer#readme))
- [Binary Wrappers](https://awesome-repositories.com/f/web-development/binary-wrappers.md) — Provides an object-oriented interface for executing and configuring system binaries.
- [Web Performance Optimization Tools](https://awesome-repositories.com/f/web-development/web-performance-optimization-tools.md) — Improves website loading speeds by reducing image file sizes.

### Development Tools & Productivity

- [Binary Orchestrators](https://awesome-repositories.com/f/development-tools-productivity/external-binary-lifecycle-managers/binary-orchestrators.md) — Coordinates the execution of pre-installed system binaries through a controlled process wrapper.
- [Automated Image Compression](https://awesome-repositories.com/f/development-tools-productivity/automated-image-compression.md) — Integrates custom optimization workflows into applications to automatically compress images.
- [Web Asset Build Pipelines](https://awesome-repositories.com/f/development-tools-productivity/workflow-automation-tools/build-task-automation/build-pipeline-integrations/web-asset-build-pipelines.md) — Automates the compression and optimization of image files during build processes.

### Graphics & Multimedia

- [Image Optimization Workflows](https://awesome-repositories.com/f/graphics-multimedia/image-optimization-workflows.md) — The project enables customization of optimization sequences and workflows by defining the order of processing tools and specific command-line arguments for image transformations. ([source](https://github.com/spatie/image-optimizer#readme))
- [PHP Image Processing](https://awesome-repositories.com/f/graphics-multimedia/php-image-processing.md) — Reduces image file sizes by chaining system-level command-line tools within the PHP runtime.
- [Image Processing Extenders](https://awesome-repositories.com/f/graphics-multimedia/image-processing-extenders.md) — The project supports extending processing capabilities by implementing interfaces for custom optimizers, allowing for unique image transformation logic beyond the default toolset. ([source](https://github.com/spatie/image-optimizer#readme))

### Software Engineering & Architecture

- [Pipeline Chaining Frameworks](https://awesome-repositories.com/f/software-engineering-architecture/pipeline-chaining-frameworks.md) — Sequences multiple independent optimization tasks into a single, reusable processing pipeline.
- [Filter-Based Logic Extensions](https://awesome-repositories.com/f/software-engineering-architecture/filter-based-logic-extensions.md) — Uses interface-based hooks to allow modification of core functionality without altering source code.

### Artificial Intelligence & ML

- [Tool Error Handling](https://awesome-repositories.com/f/artificial-intelligence-ml/tool-error-handling.md) — Provides mechanisms to define custom logic for handling optimization failures and timeouts. ([source](https://github.com/spatie/image-optimizer#readme))

### DevOps & Infrastructure

- [Execution Timeout Management](https://awesome-repositories.com/f/devops-infrastructure/job-execution-engines/execution-timeout-management.md) — Enforces strict execution limits on external system calls to prevent hung processes.
