PHPackages                             digitalzenworks/php-image-optimizer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. digitalzenworks/php-image-optimizer

ActiveLibrary[Image &amp; Media](/categories/media)

digitalzenworks/php-image-optimizer
===================================

A responsive image workflow for optimizing and resizing your images

1.5.16(2y ago)119MITPHPPHP &gt;=7.1.0

Since Apr 7Pushed 4mo agoCompare

[ Source](https://github.com/jamesjohnmcguire/PhpImageOptimizer)[ Packagist](https://packagist.org/packages/digitalzenworks/php-image-optimizer)[ Docs](https://github.com/jamesjohnmcguire/PhpImageOptimizer/)[ GitHub Sponsors](https://github.com/jamesjohnmcguire)[ RSS](/packages/digitalzenworks-php-image-optimizer/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)Dependencies (7)Versions (20)Used By (0)

PhpImageOptimizer
=================

[](#phpimageoptimizer)

A responsive image workflow for optimizing and resizing your images. Details can be found in the excellent article at [Efficient Image Resizing With ImageMagick](https://www.smashingmagazine.com/2015/06/efficient-image-resizing-with-imagemagick/)

Originally based off (forked)

Requirements/dependencies
-------------------------

[](#requirementsdependencies)

- [PHP &gt;= 7.1.0](http://php.net/)
- [ImageMagick](http://imagemagick.org/)
- [ext-imagick](http://php.net/manual/en/book.imagick.php)
- Optional: For optimization, depending on what settings you pass:

    - [SVGO](https://github.com/svg/svgo)
    - [image\_optim](https://github.com/toy/image_optim)
    - [picopt](https://github.com/ajslater/picopt)
    - [ImageOptim](https://imageoptim.com/)

Installation
------------

[](#installation)

### Git

[](#git)

git clone

### Composer

[](#composer)

composer require

Examples
--------

[](#examples)

To resize one raster image, without optimization:

```
$image = new DigitalZenWorks\ImageOptimizer($input_filename);
$image->smartResize($output_width, $output_height, false);
$image->writeImage($output_filename);
```

To resize one raster image and maintain aspect ratio, without optimization:

```
$image = new DigitalZenWorks\ImageOptimizer($input_filename);
$image->smartResize($output_width, 0, false);
$image->writeImage($output_filename);
```

To resize one raster image and maintain aspect ratio, with optimization:

```
$image = new DigitalZenWorks\ImageOptimizer($input_filename);
$image->smartResize($output_width, 0, true);
$image->writeImage($output_filename);
nwtn\Respimg::optimize($output_filename, 0, 1, 1, 1);
```

To resize a directory of raster images and maintain aspect ratio, with optimization:

```
$exts = array('jpeg', 'jpg', 'png');
if ($dir = opendir($input_path)) {
	while (($file = readdir($dir)) !== false) {
		$base = pathinfo($file, PATHINFO_BASENAME);
		$ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
		if (in_array($ext, $exts)) {
			$image = new DigitalZenWorks\ImageOptimizer($input_path . '/' . $file);
			$image->smartResize($width, 0, true);
			$image->writeImage($output_path . '/' . $base . '-w' . $w . '.' . $ext);
		}
	}
}
DigitalZenWorks\ImageOptimizer::optimize($output_path, 0, 1, 1, 1);
```

To resize a directory of raster images and SVGs and maintain aspect ratio, with optimization:

```
$exts = array('jpeg', 'jpg', 'png');
if ($dir = opendir($input_path)) {
	while (($file = readdir($dir)) !== false) {
		$base = pathinfo($file, PATHINFO_BASENAME);
		$ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
		if (in_array($ext, $exts)) {
			$image = new DigitalZenWorks\ImageOptimizer($input_path . '/' . $file);
			$image->smartResize($width, 0, true);
			$image->writeImage($output_path . '/' . $base . '-w' . $w . '.' . $ext);
		} elseif ($ext === 'svg') {
			copy($input_path . '/' . $file, $output_path . '/' . $file);
			DigitalZenWorks\ImageOptimizer::rasterize($input_path . '/' . $file, $output_path . '/', $width, 0);
		}
	}
}
DigitalZenWorks\ImageOptimizer::optimize($output_path, 3, 1, 1, 1);
```

Contributing
------------

[](#contributing)

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the Branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request

License
-------

[](#license)

Distributed under the MIT License. See `LICENSE` for more information.

Contact
-------

[](#contact)

James John McGuire - [@jamesmc](https://twitter.com/jamesmc) -

Project Link:

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance51

Moderate activity, may be stable

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 93.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~248 days

Recently: every ~140 days

Total

13

Last Release

1079d ago

Major Versions

0.0.2 → 1.0.02015-04-18

PHP version history (3 changes)0.0.1PHP &gt;=5.3.0

1.2.1PHP &gt;=5.4.0

1.4.7PHP &gt;=7.1.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/4a9e376eda04edeaf2c673778edef648297505ea1ab769bc5c807b8f4613c4b2?d=identicon)[jamesjohnmcguire](/maintainers/jamesjohnmcguire)

---

Top Contributors

[![jamesjohnmcguire](https://avatars.githubusercontent.com/u/10033525?v=4)](https://github.com/jamesjohnmcguire "jamesjohnmcguire (167 commits)")[![nwtn](https://avatars.githubusercontent.com/u/786799?v=4)](https://github.com/nwtn "nwtn (12 commits)")

---

Tags

ImageMagickimagickresizerwdResponsive Imagesrespimgresponsive web design

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/digitalzenworks-php-image-optimizer/health.svg)

```
[![Health](https://phpackages.com/badges/digitalzenworks-php-image-optimizer/health.svg)](https://phpackages.com/packages/digitalzenworks-php-image-optimizer)
```

###  Alternatives

[intervention/image

PHP Image Processing

14.3k194.3M2.2k](/packages/intervention-image)[league/glide

Wonderfully easy on-demand image manipulation library with an HTTP based API.

2.6k51.2M116](/packages/league-glide)[intervention/image-laravel

Laravel Integration of Intervention Image

1496.5M102](/packages/intervention-image-laravel)[francodacosta/phmagick

image manipulation with php and ImageMagick

3869.7k1](/packages/francodacosta-phmagick)[orbitale/imagemagick-php

A system that allows creating commands to send to the exec() function to use ImageMagick's powerful features.

43385.7k1](/packages/orbitale-imagemagick-php)[admad/cakephp-glide

CakePHP plugin for using Glide image manipulation library.

34160.7k1](/packages/admad-cakephp-glide)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
