PHPackages                             contao/image - 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. contao/image

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

contao/image
============

Contao image library

1.2.4(7mo ago)131.8M↓71.8%7[5 issues](https://github.com/contao/image/issues)[2 PRs](https://github.com/contao/image/pulls)9LGPL-3.0-or-laterPHPPHP ^7.2 || ^8.0CI passing

Since Jul 29Pushed 7mo ago7 watchersCompare

[ Source](https://github.com/contao/image)[ Packagist](https://packagist.org/packages/contao/image)[ Fund](https://to.contao.org/donate)[ RSS](/packages/contao-image/feed)WikiDiscussions 1.x Synced 2w ago

READMEChangelog (10)Dependencies (11)Versions (29)Used By (9)

Contao image library
====================

[](#contao-image-library)

[![](https://camo.githubusercontent.com/2f8ef2fec8dac3905c39756a6502de592086bdc66bc828988892819018e28936/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f636f6e74616f2f696d6167652f63692e796d6c3f6272616e63683d312e78267374796c653d666c61742d737175617265)](https://github.com/contao/image/actions?query=branch%3A1.x)[![](https://camo.githubusercontent.com/94756c40b3bad86cb39893dcffdcde03ca2e95b3582a659cf7337416e79e4567/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f636f6e74616f2f696d6167652f312e782e7376673f7374796c653d666c61742d737175617265)](https://codecov.io/gh/contao/image)[![](https://camo.githubusercontent.com/87ebb13e885604c57b51f96aab02ebd601db187df7489ec51327a60ee6dd3e1f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636f6e74616f2f696d6167652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/contao/image)[![](https://camo.githubusercontent.com/fb5f824a826de455c3521459920c16578cd26877ade65b655a0811f96b6d6d42/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636f6e74616f2f696d6167652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/contao/image)

This library provides methods to resize images based on resize configurations and generates responsive images to be used with `` and `srcset`. It is used in [Contao](https://contao.org) to handle on-the-fly resizing of images.

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

[](#installation)

```
php composer.phar require contao/image
```

Usage
-----

[](#usage)

### Simple resize:

[](#simple-resize)

```
$imagine = new \Imagine\Gd\Imagine();
$resizer = new Resizer('/path/to/cache/dir');
$image = new Image('/path/to/image.jpg', $imagine);

$config = (new ResizeConfiguration())
    ->setWidth(100)
    ->setHeight(100)
    ->setMode(ResizeConfiguration::MODE_CROP)
;

$options = (new ResizeOptions())
    ->setImagineOptions([
        'jpeg_quality' => 95,
        'interlace' => \Imagine\Image\ImageInterface::INTERLACE_PLANE,
    ])
    ->setBypassCache(true)
    ->setTargetPath('/custom/target/path.jpg')
;

$resizedImage = $resizer->resize($image, $config, $options);

$resizedImage->getPath(); // /custom/target/path.jpg
$resizedImage->getUrl('/custom/target'); // path.jpg
$resizedImage->getUrl('/custom/target', 'https://example.com/'); // https://example.com/path.jpg
```

### Responsive image:

[](#responsive-image)

```
$imagine = new \Imagine\Gd\Imagine();

$resizer = new Resizer('/path/to/cache/dir');
$pictureGenerator = new PictureGenerator($resizer);
$image = new Image('/path/to/image.jpg', $imagine);

$config = (new PictureConfiguration())
    ->setSize((new PictureConfigurationItem())
        ->setResizeConfig((new ResizeConfiguration())
            ->setWidth(100)
            ->setHeight(100)
            ->setMode(ResizeConfiguration::MODE_CROP)
        )
        ->setDensities('1x, 2x')
        ->setSizes('100vw')
    )
    ->setSizeItems([
        (new PictureConfigurationItem())
            ->setResizeConfig((new ResizeConfiguration())
                ->setWidth(400)
                ->setHeight(200)
                ->setMode(ResizeConfiguration::MODE_CROP)
            )
            ->setDensities('1x, 2x')
            ->setSizes('100vw')
            ->setMedia('(min-width: 900px)')
    ])
;

$options = (new ResizeOptions());
$picture = $pictureGenerator->generate($image, $config, $options);

$picture->getImg('/path/to');
/* [
    'src' => 'cache/dir/4/image-de332f09.jpg',
    'width' => 100,
    'height' => 100,
    'srcset' => 'cache/dir/4/image-de332f09.jpg 100w, cache/dir/4/image-9e0829dd.jpg 200w',
    'sizes' => '100vw',
] */

$picture->getSources('/path/to', 'https://example.com/');
/* [
    [
        'src' => 'https://example.com/cache/dir/c/image-996db4cf.jpg',
        'width' => 400,
        'height' => 200,
        'srcset' => 'https://example.com/cache/dir/c/image-996db4cf.jpg 400w, https://example.com/cache/dir/2/image-457dc5e0.jpg 800w',
        'sizes' => '100vw',
        'media' => '(min-width: 900px)',
    ],
] */
```

###  Health Score

57

—

FairBetter than 98% of packages

Maintenance57

Moderate activity, may be stable

Popularity49

Moderate usage in the ecosystem

Community31

Small or concentrated contributor base

Maturity79

Established project with proven stability

 Bus Factor1

Top contributor holds 74.6% 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 ~123 days

Recently: every ~146 days

Total

29

Last Release

210d ago

Major Versions

0.3.9 → 1.0.0-beta12019-06-16

PHP version history (6 changes)0.1.0PHP &gt;=5.5.0

0.3.5PHP ^5.6|^7.0

0.3.7PHP ^5.6 || ^7.0

1.0.0-beta1PHP ^7.1

1.0.3PHP ^7.1 || ^8.0

1.1.2PHP ^7.2 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/3de3a0dd7c29df679eb280585220c17c1a7340b46c2792d5e8298be859acfbba?d=identicon)[leofeyer](/maintainers/leofeyer)

![](https://www.gravatar.com/avatar/8c7bdddffcaec444b7891b633f45fe2713d2b04ff21a6362fd748720d0822d58?d=identicon)[ausi](/maintainers/ausi)

---

Top Contributors

[![ausi](https://avatars.githubusercontent.com/u/367169?v=4)](https://github.com/ausi "ausi (220 commits)")[![leofeyer](https://avatars.githubusercontent.com/u/1192057?v=4)](https://github.com/leofeyer "leofeyer (66 commits)")[![aschempp](https://avatars.githubusercontent.com/u/1073273?v=4)](https://github.com/aschempp "aschempp (3 commits)")[![Toflar](https://avatars.githubusercontent.com/u/481937?v=4)](https://github.com/Toflar "Toflar (3 commits)")[![m-vo](https://avatars.githubusercontent.com/u/5305677?v=4)](https://github.com/m-vo "m-vo (2 commits)")[![xchs](https://avatars.githubusercontent.com/u/1218766?v=4)](https://github.com/xchs "xchs (1 commits)")

---

Tags

cmscontaoimagephpresizer

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/contao-image/health.svg)

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

###  Alternatives

[composer/composer

Composer helps you declare, manage and install dependencies of PHP projects. It ensures you have the right stack everywhere.

29.5k199.6M3.4k](/packages/composer-composer)[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k18.3M430](/packages/easycorp-easyadmin-bundle)[symfony/framework-bundle

Provides a tight integration between Symfony components and the Symfony full-stack framework

3.6k257.3M12.4k](/packages/symfony-framework-bundle)[symfony/config

Helps you find, load, combine, autofill and validate configuration values of any kind

4.3k488.4M9.3k](/packages/symfony-config)[sulu/sulu

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

1.3k1.4M236](/packages/sulu-sulu)[friendsofphp/php-cs-fixer

A tool to automatically fix PHP code style

13.5k257.0M28.1k](/packages/friendsofphp-php-cs-fixer)

PHPackages © 2026

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