PHPackages                             uxcode-fr/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. uxcode-fr/image-optimizer

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

uxcode-fr/image-optimizer
=========================

Converts PNG/JPG images to AVIF, WebP and JPG in multiple sizes via Imagick.

1.0.6(2mo ago)61.5k↑2122.2%1MITPHPPHP &gt;=8.1

Since Mar 20Pushed 2mo agoCompare

[ Source](https://github.com/uxcode-fr/image-optimizer)[ Packagist](https://packagist.org/packages/uxcode-fr/image-optimizer)[ Docs](https://github.com/uxcode-fr/image-optimizer)[ RSS](/packages/uxcode-fr-image-optimizer/feed)WikiDiscussions main Synced 2w ago

READMEChangelogDependencies (6)Versions (8)Used By (0)

Image Optimizer
===============

[](#image-optimizer)

**Converts PNG/JPG images to AVIF, WebP and JPG in multiple sizes.**

Works with **Laravel**, **Symfony**, and **vanilla PHP** projects.

[![Screenshot](https://raw.githubusercontent.com/uxcode-fr/image-optimizer/main/screenshot.png)](https://raw.githubusercontent.com/uxcode-fr/image-optimizer/main/screenshot.png)

---

Why use it?
-----------

[](#why-use-it)

Modern web performance starts with images. They typically account for **50–80% of a page's total weight** — and they are the first thing Lighthouse, PageSpeed Insights, and Core Web Vitals will flag.

### Next-gen formats

[](#next-gen-formats)

AVIF and WebP deliver the same visual quality as JPEG at a fraction of the size:

FormatTypical size vs JPGJPGbaselineWebP~30% smallerAVIF~50% smallerThe browser automatically picks the best format it supports via `` / `srcset`. JPG is kept as a universal fallback.

### Responsive images &amp; HiDPI

[](#responsive-images--hidpi)

Serving a 1200px image on a 300px thumbnail wastes bandwidth and slows down the page. With this tool you define the exact widths you need per image category, and `@2x` / `@3x` variants are generated automatically for Retina and HiDPI screens — so every device downloads only what it needs.

### PageSpeed &amp; Lighthouse impact

[](#pagespeed--lighthouse-impact)

Optimizing images directly improves the metrics that matter most:

- **LCP (Largest Contentful Paint)** — the main image loads faster
- **Total Blocking Time** — less network contention
- **Serve images in next-gen formats** — the most common PageSpeed recommendation, resolved
- **Properly size images** — resolved by generating the right widths
- **Efficiently encode images** — resolved by tunable per-format quality

### Build-time, zero runtime cost

[](#build-time-zero-runtime-cost)

Images are generated once at build time — no on-the-fly processing, no extra server load, no CDN dependency. The output is plain static files you deploy like any other asset.

---

Prerequisites
-------------

[](#prerequisites)

Requires the **PHP Imagick extension** on your system.

```
# Ubuntu / Debian
sudo apt install -y php-imagick

# macOS
brew install imagemagick && pecl install imagick
```

---

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

[](#installation)

```
composer require --dev uxcode-fr/image-optimizer
```

---

Configuration
-------------

[](#configuration)

### Laravel

[](#laravel)

```
php artisan vendor:publish --tag=image-optimizer-config
```

### Symfony / vanilla PHP

[](#symfony--vanilla-php)

```
cp vendor/uxcode-fr/image-optimizer/config/image-optimizer.php config/image-optimizer.php
```

### config/image-optimizer.php

[](#configimage-optimizerphp)

```
return [
    'source'      => 'resources/images',
    'destination' => 'public/img',

    'quality' => [
        'avif' => 60,
        'webp' => 82,
        'jpg'  => 85,
    ],

    'formats'   => ['avif', 'webp', 'jpg'],
    'densities' => [1, 2],

    'folders' => [
        'product' => [200, 280],   // generates -200, -200@2x, -280, -280@2x variants
        'author'  => [48, 128],
        'article' => null,         // convert only, no resize
    ],
];
```

### Via composer.json (fallback)

[](#via-composerjson-fallback)

```
{
  "extra": {
    "image-optimizer": {
      "source": "resources/images",
      "destination": "public/img",
      "quality": { "avif": 60, "webp": 82, "jpg": 85 },
      "formats": ["avif", "webp", "jpg"],
      "densities": [1, 2],
      "folders": {
        "product": [200, 280],
        "author": [48, 128]
      }
    }
  }
}
```

---

Usage
-----

[](#usage)

```
# Process all images
vendor/bin/image-optimizer

# Process only one folder
vendor/bin/image-optimizer --folder=product

# Force regeneration of existing images
vendor/bin/image-optimizer --force

# Delete generated images with no matching source
vendor/bin/image-optimizer --clean
```

### Output example

[](#output-example)

```
🖼️   Optimizing product/hero.png (245 KB)...
  ✓  public/img/product/hero-200.avif (12 KB, -95% 🚀)
  ✓  public/img/product/hero-200.webp (18 KB, -93% 🚀)
  ✓  public/img/product/hero-200.jpg (22 KB, -91% 🚀)
  ✓  public/img/product/hero-200@2x.avif (38 KB, -84% 🚀)
  ✓  public/img/product/hero-200@2x.webp (52 KB, -79% 🚀)
  ✓  public/img/product/hero-200@2x.jpg (61 KB, -75% 🚀)

🖼️   Optimizing author/avatar.png (18 KB)...
  –  public/img/author/avatar-48.avif (skipped)
  –  public/img/author/avatar-48.webp (skipped)
  –  public/img/author/avatar-48.jpg (skipped)

6 image(s) generated, 3 skipped, 0 deleted.

```

---

HTML usage examples
-------------------

[](#html-usage-examples)

### `` with multiple formats and sizes

[](#picture-with-multiple-formats-and-sizes)

```

```

The browser picks the first `` it supports, from top to bottom — AVIF first, then WebP, then JPG as a universal fallback.

### Simple `srcset` (single format, multiple widths)

[](#simple-srcset-single-format-multiple-widths)

```

```

### Avatar (fixed size, HiDPI only)

[](#avatar-fixed-size-hidpi-only)

```

```

### Laravel Blade

[](#laravel-blade)

```

```

---

Configuration options
---------------------

[](#configuration-options)

KeyDefaultDescription`source``resources/images`Source folder (PNG/JPG), relative to project root`destination``public/img`Output folder, relative to project root`quality``['avif'=>60, 'webp'=>82, 'jpg'=>85]`Compression quality per format (1–100)`formats``['avif', 'webp', 'jpg']`Output formats — any subset of `avif`, `webp`, `jpg``densities``[1, 2]`Pixel density multipliers (`1` = base, `2` = @2x…)`folders``[]`Per-folder width list (`null` = convert only)### Obsolete image cleanup

[](#obsolete-image-cleanup)

Pass `--clean` to delete generated files that no longer have a matching source image (only for folders declared in `folders`).

---

License
-------

[](#license)

MIT — Copyright 2026 [uxcode.fr](https://uxcode.fr)

###  Health Score

44

—

FairBetter than 91% of packages

Maintenance83

Actively maintained with recent releases

Popularity27

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~1 days

Total

7

Last Release

88d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2263103?v=4)[Arnaud Lemercier](/maintainers/arnolem)[@arnolem](https://github.com/arnolem)

---

Top Contributors

[![arnolem](https://avatars.githubusercontent.com/u/2263103?v=4)](https://github.com/arnolem "arnolem (13 commits)")

---

Tags

devimageoptimizationresponsiveWebpavif

### Embed Badge

![Health badge](/badges/uxcode-fr-image-optimizer/health.svg)

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

###  Alternatives

[laravel/framework

The Laravel Framework.

34.8k532.1M19.4k](/packages/laravel-framework)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

19564.8M1.6k](/packages/drupal-core)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.4M196](/packages/sulu-sulu)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.4M514](/packages/shopware-core)[friendsoftypo3/content-blocks

TYPO3 CMS Content Blocks - Content Types API | Define reusable components via YAML

101466.4k45](/packages/friendsoftypo3-content-blocks)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

9317.2k55](/packages/open-dxp-opendxp)

PHPackages © 2026

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