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

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

webiny/image
============

Webiny Image Component

v1.6.1(8y ago)019MITPHPPHP ^7

Since Sep 20Pushed 8y ago8 watchersCompare

[ Source](https://github.com/Webiny/Image)[ Packagist](https://packagist.org/packages/webiny/image)[ Docs](http://www.webiny.com/)[ RSS](/packages/webiny-image/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (1)Dependencies (7)Versions (23)Used By (0)

Image Component
===============

[](#image-component)

The `Image` component provides basic functions for manipulating images. Component also fixes the incorrect rotation on pictures taken by a smartphone like iPhone or Android.

Install the component
---------------------

[](#install-the-component)

The best way to install the component is using Composer.

```
composer require webiny/image
```

For additional versions of the package, visit the [Packagist page](https://packagist.org/packages/webiny/image).

Usage
-----

[](#usage)

This component is deeply coupled with the `Storage` component, so it's advised that you get yourself familiar with that component first, if you already haven't.

Under **basic functions** it's meant that you can do these manipulations on any image:

- `resize`
- `crop`
- `rotate`

But before you can do any of the manipulations, you must first load an image. You can load an image from several different sources by calling appropriate methods on `ImageLoader` class:

- `create` - creates a blank image
- `open` - create an image from the given File storage instance
- `load` - create an image from the given binary string
- `resource` - create an image from the given (stream) resource

Each of these methods returns an instance of `ImageInterface`. Using `ImageInterface` you can perform the defined manipulations on the loaded image.

Once you are done manipulating the image you can either save it by calling the `save` method, or you can output the image by calling the `show` method.

Here is a usage example:

```
// storage
$imageStorage = \Webiny\Component\ServiceManager\ServiceManager::getInstance()->getService('storage.local');
$image = new \Webiny\Component\Storage\File\File('embed.jpg', $imageStorage);

// load the image using the `open` method
$imgInstance = \Webiny\Component\Image\ImageLoader::open($image);

// perform manipulations
$imgInstance->resize(800, 800)
            ->crop(200, 200, 50, 40);
            ->rotate(30, 'bfbfbf');

// save the new image
$destination = new \Webiny\Component\Storage\File\File('embed-rotated.jpg', $imageStorage);
$result = $imgInstance->save($destination); // if you don't set the destination, the original image will be overwritten
```

Using ImageTrait
----------------

[](#using-imagetrait)

An easier way of loading the image and creating instances of ImageInterface is using the ImageTrait. Here is an example of loading the image from the \\Webiny\\Component\\Storage\\File\\File object:

```
class MyClass{
	use \Webiny\Component\Image\ImageTrait;

	function __construct(){
		$imageStorage = \Webiny\Component\ServiceManager\ServiceManager::getInstance()->getService('Storage.Local');
		$image = new \Webiny\Component\Storage\File\File('embed.jpg', $imageStorage);

		$imgInstance = $this->image($image);

		$imgInstance->resize(800, 800);
		$imgInstance->crop(200, 200, 50, 40);
		$imgInstance->rotate(30, 'bfbfbf');

		$imgInstance->show();
	}
}
```

Here is another example where we load the image by file storage key and storage driver:

```
class MyClass{
	use \Webiny\Component\Image\ImageTrait;

	function __construct(){
		$imgInstance = $this->image('embed.jpg', 'Local');

		$imgInstance->resize(800, 800);
		$imgInstance->crop(200, 200, 50, 40);
		$imgInstance->rotate(30, 'bfbfbf');

		$imgInstance->show();
	}
}
```

So as you can see, you can load and create ImageInterface instances either by passing directly the File object, or by passing the file key together with the name of the storage service.

Bridge
------

[](#bridge)

The default bridge for image library uses `Imagine` library () by Bulat Shakirzyanov which perform all the image manipulations.

If you wish to expand or change the current bridged library you need to create two classes:

- a loader class that implements `Webiny\Component\Image\Bridge\ImageLoaderInterface`
- an image manipulation class that extends `Webiny\Component\Image\Bridge\AbstractImage`

After that just change the `Bridge` in the configuration and the framework will use your bridge instead the default one.

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

[](#configuration)

The `Image` component requires very little configuration. Here is an example:

```
    Image:
        Library: gd
        Quality: 90
```

The `Library` parameter defines which image library will be used. Supported libraries by `Imagine` library are:

- `gd` - uses native PHPs GD library
- `imagick` - uses ImageMagick library which requires php-imagick extension
- `gmagick` - uses GraphicsMagick API which also requires php-gmagick extension

The `Quality` parameter defines at which quality to save the image. The default quality is 90 (max is 100).

To register the config with the component, just call `Image::setConfig($pathToYamlConfig)`.

Resources
---------

[](#resources)

To run unit tests, you need to use the following command:

```
$ cd path/to/Webiny/Component/Image/
$ composer.phar install
$ phpunit

```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity73

Established project with proven stability

 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 ~52 days

Recently: every ~5 days

Total

22

Last Release

3154d ago

PHP version history (3 changes)v1.0.0PHP &gt;=5.4.0

v1.2.1PHP &gt;=5.5.9

v1.5.0PHP ^7

### Community

Maintainers

![](https://www.gravatar.com/avatar/4440afa738ed146b05c06073a90345e0464c4f4d042b039532d881ca24859d77?d=identicon)[SvenAlHamad](/maintainers/SvenAlHamad)

---

Top Contributors

[![SvenAlHamad](https://avatars.githubusercontent.com/u/3808420?v=4)](https://github.com/SvenAlHamad "SvenAlHamad (27 commits)")

---

Tags

imagegdimagickresizegmagickcrop

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[intervention/image

PHP Image Processing

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

Powerful PHP class using GD library to work easily with images including layer notion (like Photoshop or GIMP)

860918.1k11](/packages/sybio-image-workshop)[intervention/image-laravel

Laravel Integration of Intervention Image

1536.5M102](/packages/intervention-image-laravel)[folklore/image

Image manipulation library for Laravel 5 based on Imagine and inspired by Croppa for easy url based manipulation

270248.2k5](/packages/folklore-image)[jbzoo/image

A PHP class that simplifies working with images

171126.9k3](/packages/jbzoo-image)[stefangabos/zebra_image

A single-file, lightweight PHP library designed for efficient image manipulation featuring methods for modifying images and applying filters

141110.4k6](/packages/stefangabos-zebra-image)

PHPackages © 2026

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