PHPackages                             joomla/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. [Framework](/categories/framework)
4. /
5. joomla/image

AbandonedArchivedJoomla-package[Framework](/categories/framework)

joomla/image
============

Joomla Image Package

1.5.1(5y ago)1271.4k15GPL-2.0-or-laterPHPPHP ^5.3.10|~7.0CI failing

Since Jun 4Pushed 4y ago11 watchersCompare

[ Source](https://github.com/joomla-framework/image)[ Packagist](https://packagist.org/packages/joomla/image)[ Docs](https://github.com/joomla-framework/image)[ Fund](https://community.joomla.org/sponsorship-campaigns.html)[ GitHub Sponsors](https://github.com/joomla)[ RSS](/packages/joomla-image/feed)WikiDiscussions 2.0-dev Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (19)Used By (0)

The Image Package [![Build Status](https://camo.githubusercontent.com/cfac6a9ee241fe3083f7c54d54a0e9fb3700eb69016492205f700bb6b21e9b5d/68747470733a2f2f63692e6a6f6f6d6c612e6f72672f6170692f6261646765732f6a6f6f6d6c612d6672616d65776f726b2f696d6167652f7374617475732e737667)](https://ci.joomla.org/joomla-framework/image)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

[](#the-image-package-)

[![Latest Stable Version](https://camo.githubusercontent.com/30fa28cc1d543746c5ca70e946efac70a8747668f90f6d2e17381bcdd91b9219/68747470733a2f2f706f7365722e707567782e6f72672f6a6f6f6d6c612f696d6167652f762f737461626c65)](https://packagist.org/packages/joomla/image)[![Total Downloads](https://camo.githubusercontent.com/ffe902e386af17849167aa9abee10503bbeec0aa6561f1ac998d61605ac4cb3e/68747470733a2f2f706f7365722e707567782e6f72672f6a6f6f6d6c612f696d6167652f646f776e6c6f616473)](https://packagist.org/packages/joomla/image)[![Latest Unstable Version](https://camo.githubusercontent.com/79824e09e0b43b3680a2606e444edcca6d0e0252175b5e93c64e3170eac7a7d8/68747470733a2f2f706f7365722e707567782e6f72672f6a6f6f6d6c612f696d6167652f762f756e737461626c65)](https://packagist.org/packages/joomla/image)[![License](https://camo.githubusercontent.com/01bee89ea27c8f4f77451f3cc8412ad5553e4f0f63d7d94b006e241634b2c6f6/68747470733a2f2f706f7365722e707567782e6f72672f6a6f6f6d6c612f696d6167652f6c6963656e7365)](https://packagist.org/packages/joomla/image)

This package comprises of 2 main classes, `Image` and `ImageFilter` which has 8 filter sub-classes that it can use to apply a desired filter to your image. `Image` depends on the `GD` php extension to be loaded on your server. More information on `GD` can be found at:

Manipulating images in raw PHP using the `GD` image\* functions requires a lot of boilerplate code. The intent of this package is to handle those requirements and make it simple for developers to accomplish those tasks through easy to use (and remember) methods.

All classes in this package are supported by the auto-loader so can be invoked at any time.

### Deprecated

[](#deprecated)

The `joomla/image` package is deprecated with no future updates planned.

### Construction

[](#construction)

When creating a new `Image` object, the constructor will check that the `gd` extension is loaded, and throw a `RuntimeException` if it is not.

The constructor takes a single optional `$source` parameter. This argument can be one of two things:

- A variable containing an existing, valid image resource created using a `imagecreate*` method.
- A string containing a valid, absolute path to an image

If you choose the first option, the class sets the protected property `$handle` to the provided image resource. If you choose the second option, the class will call the `loadFile` method, passing along the `$source` parameter.

```
use Joomla\Image\Image;

// Creating a new Image object, passing it an existing handle.
$resource = imagecreate(100, 100);
$image = new Image($resource);

// Creating a new Image object, passing it an image path
$image = new Image(JPATH_ROOT . '/media/com_foo/images/uploads/bar.png');

// Creating a new Image object then manually calling `loadFile`
$image = new Image;
$image->loadFile(JPATH_ROOT . '/media/com_foo/images/uploads/bar.png');
```

### Usage

[](#usage)

Keep in mind that most public methods return a `Image` instance with a valid image handle for easy method chaining. The examples for each method will break each method call out to be able to comment on what the code is doing, but production code can be chained like so (if you prefer):

```
use Joomla\Image\Image;

$image = new Image();
$image->loadFile(JPATH_ROOT . '/path/to/image.png')
	->crop(600, 250)
	->toFile(JPATH_ROOT . '/tmp/image.png');
```

Since Platform version 12.3, there is a new `destroy()` method that gets called in appropriate places throughout the class which runs the `imagedestroy` function to free memory associated with an image handle. This method is called before each time an image handle is replaced (when `$createNew` is set to false) as well as in the class `__descruct` method as a final cleanup.

#### The `resize` method

[](#the-resize-method)

**Accepted Parameters**

- `$width`: The width of the resized image in pixels or a percentage.
- `$height`: The height of the resized image in pixels or a percentage.
- `$createNew`: If true the current image will be cloned, resized and returned; else the current image will be resized and returned.
- `$scaleMethod`: Which method to use for scaling

Example: Using `Image::resize()` to generate a resized image.

```
use Joomla\Image\Image;

// Create our image object
$image = new Image(JPATH_ROOT . '/media/com_foo/images/uploads/bar.png');

// Resize the image using the SCALE_INSIDE method
$image_resized = $image->resize(300, 150, true, Image::SCALE_INSIDE);

// Write it to disk
$image_resized->toFile(JPATH_ROOT . '/tmp/bar_resized.png');
```

#### The `crop` method

[](#the-crop-method)

**Accepted Parameters**

- `$width`: The width of the image section to crop in pixels or a percentage.
- `$height`: The height of the image section to crop in pixels or a percentage.
- `$left`: The number of pixels from the left to start cropping.
- `$top`: The number of pixels from the top to start cropping.
- `$createNew`: If true the current image will be cloned, cropped and returned; else the current image will be cropped and returned.

Example: Using `Image::crop()` to generate a cropped image.

```
use Joomla\Image\Image;

// Create our image object
$image = new Image(JPATH_ROOT . '/media/com_foo/images/uploads/bar.png');

// Crop the image to 150px square, starting 10 pixels from the left, and 20 pixels from the top
$image_resized = $image->crop(150, null, 10, 20);

// Write it to disk
$image_resized->toFile(JPATH_ROOT . '/tmp/bar_cropped.png');
```

To crop in image after resizing it to maintain proportions use `cropResize` method with familiar arguments `$width`, `$height` and `$createNew`.

#### The `createThumbs` method

[](#the-createthumbs-method)

**Accepted Parameters**

- `$thumbSizes`: String or array of strings. Example: $thumbSizes = array('150x75','250x150');
- `$creationMethod`: See **Resize Methods** below.
- `$thumbsFolder`: Destination for thumbnails. Passing null generates a thumbs folder in the loaded image's containing folder.

Example: Using `Image::createThumbs()` to generate thumbnails of an image.

```
use Joomla\Image\Image;

// Set the desired sizes for our thumbnails.
$sizes = array('300x300', '64x64', '250x125');

// Create our object
$image = new Image(JPATH_ROOT . '/media/com_foo/images/uploads/uploadedImage.jpg');

// Create the thumbnails
$image->createThumbs($sizes, Image::SCALE_INSIDE);
```

In this example, we use the `createThumbs` method of `Image`. This method takes 2 parameters. The first parameter can be a string containing a single size in `WIDTHxHEIGHT` format, or it can be an array of sizes in the format (as shown in the example). The second parameter specifies the resize method. (See Resize Methods below)

To receive Image instances without saving them to disk, use `generateThumbs` method with arguments `$thumbSizes` and `$creationMethod`.

#### Resize Methods

[](#resize-methods)

The `resize`, `createThumbs` and `generateThumbs` methods take an optional parameter that defines what method to use when scaling an image. This parameter can be one of the following:

- `Image::SCALE_FILL` - Gives you a thumbnail of the exact size, stretched or squished to fit the parameters.
- `Image::SCALE_INSIDE` - Fits your thumbnail within your given parameters. It will not be any taller or wider than the size passed, whichever is larger.
- `Image::SCALE_OUTSIDE` - Fits your thumbnail to the given parameters. It will be as tall or as wide as the size passed, whichever is smaller.
- `Image::SCALE_FIT` - Fits your thumbnail to given boundaries maintaining aspect ratio. Result will be aligned vertically to center and horizontally to middle.
- `Image::CROP` - Gives you a thumbnail of the exact size, cropped from the center of the full sized image.
- `Image::CROP_RESIZE` - As above, but gives a clean resize and crop from center.

#### The `toFile` method

[](#the-tofile-method)

**Accepted Parameters**

- `$path`: The filesystem path to save the image. When null, the raw image stream will be outputted directly.
- `$type`: The image type to save the file as (`IMAGETYPE_GIF`|`IMAGETYPE_PNG`|`IMAGETYPE_JPEG`).
- `$options`: The image type options to use in saving the file. Use `quality` key to set compression level (0..9 for PNGs and 0..100 for JPEGs)

Example: Using `Image::toFile()` to save the image as JPEG with 65 compression level

```
use Joomla\Image\Image;

// Create our object
$image = new Image(JPATH_ROOT . '/media/com_foo/images/uploads/bar.png');

// Write to disk
$image->toFile(JPATH_ROOT . '/tmp/bar.jpg', IMAGETYPE_JPEG, array('options' => 65));
```

Example: Using `Image::toFile()` to retrieve data blob of an image.

```
use Joomla\Image\Image;

// Create our object
$image = new Image(JPATH_ROOT . '/media/com_foo/images/uploads/bar.png');

// Enable output buffering
ob_start();

// Retrieve data blob
$image->toFile(null, IMAGETYPE_PNG);
$imageBlob = ob_get_clean();
```

Installation via Composer
-------------------------

[](#installation-via-composer)

Add `"joomla/image": "2.0.*@dev"` to the require block in your composer.json and then run `composer install`.

```
{
	"require": {
		"joomla/image": "2.0.*@dev"
	}
}
```

Alternatively, you can simply run the following from the command line:

```
composer require joomla/image "2.0.*@dev"
```

If you want to include the test sources, use

```
composer require --prefer-source joomla/image "~1.0"
```

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity39

Limited adoption so far

Community25

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 57.1% 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 ~171 days

Recently: every ~384 days

Total

17

Last Release

1993d ago

PHP version history (3 changes)1.0-alphaPHP &gt;=5.3.10

1.1.6PHP &gt;=5.3.10|&gt;=7.0

1.2.0PHP ^5.3.10|~7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/305a2164440014dcef9ac681c139fe5e8a1ce1d7a8c3b3cfb828497729a4c70e?d=identicon)[wilsonge](/maintainers/wilsonge)

---

Top Contributors

[![mbabker](https://avatars.githubusercontent.com/u/368545?v=4)](https://github.com/mbabker "mbabker (80 commits)")[![nibra](https://avatars.githubusercontent.com/u/827605?v=4)](https://github.com/nibra "nibra (20 commits)")[![dongilbert](https://avatars.githubusercontent.com/u/718028?v=4)](https://github.com/dongilbert "dongilbert (14 commits)")[![ianmacl](https://avatars.githubusercontent.com/u/176534?v=4)](https://github.com/ianmacl "ianmacl (5 commits)")[![Achal-Aggarwal](https://avatars.githubusercontent.com/u/3330262?v=4)](https://github.com/Achal-Aggarwal "Achal-Aggarwal (3 commits)")[![wilsonge](https://avatars.githubusercontent.com/u/1986000?v=4)](https://github.com/wilsonge "wilsonge (3 commits)")[![aliasm2k](https://avatars.githubusercontent.com/u/29655345?v=4)](https://github.com/aliasm2k "aliasm2k (2 commits)")[![realityking](https://avatars.githubusercontent.com/u/628508?v=4)](https://github.com/realityking "realityking (2 commits)")[![eddieajau](https://avatars.githubusercontent.com/u/700871?v=4)](https://github.com/eddieajau "eddieajau (2 commits)")[![nicolallias](https://avatars.githubusercontent.com/u/5197407?v=4)](https://github.com/nicolallias "nicolallias (1 commits)")[![PhilETaylor](https://avatars.githubusercontent.com/u/400092?v=4)](https://github.com/PhilETaylor "PhilETaylor (1 commits)")[![photodude](https://avatars.githubusercontent.com/u/10253980?v=4)](https://github.com/photodude "photodude (1 commits)")[![piotr-cz](https://avatars.githubusercontent.com/u/612953?v=4)](https://github.com/piotr-cz "piotr-cz (1 commits)")[![zero-24](https://avatars.githubusercontent.com/u/2596554?v=4)](https://github.com/zero-24 "zero-24 (1 commits)")[![xillibit](https://avatars.githubusercontent.com/u/876395?v=4)](https://github.com/xillibit "xillibit (1 commits)")[![Hackwar](https://avatars.githubusercontent.com/u/313866?v=4)](https://github.com/Hackwar "Hackwar (1 commits)")[![laoneo](https://avatars.githubusercontent.com/u/251072?v=4)](https://github.com/laoneo "laoneo (1 commits)")[![ChrisFrench](https://avatars.githubusercontent.com/u/210848?v=4)](https://github.com/ChrisFrench "ChrisFrench (1 commits)")

---

Tags

gdimagejoomlajoomla-frameworkphpframeworkimagejoomla

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[laravel/framework

The Laravel Framework.

34.7k509.9M17.0k](/packages/laravel-framework)[cakephp/cakephp

The CakePHP framework

8.8k18.5M1.6k](/packages/cakephp-cakephp)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[joomla/application

Joomla Application Package

23404.8k11](/packages/joomla-application)[joomla/registry

Joomla Registry Package

16468.6k20](/packages/joomla-registry)[joomla/filesystem

Joomla Filesystem Package

12369.7k7](/packages/joomla-filesystem)

PHPackages © 2026

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