PHPackages                             mistralys/application-utils-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. mistralys/application-utils-image

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

mistralys/application-utils-image
=================================

PHP image helper library for basic image operations and color management.

1.2.0(1y ago)232.6k↓11%3MITPHPPHP &gt;=7.4

Since Dec 3Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Mistralys/application-utils-image)[ Packagist](https://packagist.org/packages/mistralys/application-utils-image)[ RSS](/packages/mistralys-application-utils-image/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (5)Versions (5)Used By (3)

AppUtils - Image Helper
=======================

[](#apputils---image-helper)

PHP image helper library for basic image editing and color management.

Features
========

[](#features)

- Dedicated image file classes, e.g. `JPGFile`, `SVGFile`.
- Resample images by width, height, or both.
- Get image dimensions, SVG files included.
- Crop images.
- Sharpen images.
- Trim images.
- Work with alpha transparency.
- Add text to images.
- Calculate the average color of an image.
- Calculate the brightness or luma value of an image.
- Work with a mix of HEX, 8Bit, 7Bit and percentage-based color values.

Requirements
============

[](#requirements)

- PHP 7.4 or higher
- [Composer](https://getcomposer.org)
- GD extension

Usage
=====

[](#usage)

Image file classes
------------------

[](#image-file-classes)

The library provides classes for handling different image formats:

- `GIFFile`
- `JPGFile` and `JPEGFile`
- `PNGFile`
- `SVGFile`

These classes work like the `FileInfo` class provided by the File Helper, so they provide all typical file operation methods as well as specialized image-related methods.

Simple image operations
-----------------------

[](#simple-image-operations)

The image file class methods will immediately save the modifications to the file system. If you want to perform multiple operations before saving, you will have to use an `ImageHelper` instance instead.

### Resampling by width

[](#resampling-by-width)

This resamples the image to a new width, adjusting the height to keep the original image aspect ratio.

```
use AppUtils\ImageHelper\ImageFiles\FileTypes\JPGFile;

JPGFile::factory('image.jpg')
    ->resampleByWidth('resized.jpg', 200);
```

### Resampling by height

[](#resampling-by-height)

This resamples the image to a new height, adjusting the width to keep the original image aspect ratio.

```
use AppUtils\ImageHelper\ImageFiles\FileTypes\JPGFile;

JPGFile::factory('image.jpg')
    ->resampleByHeight('resized.jpg', 200);
```

### Resampling without the aspect ratio

[](#resampling-without-the-aspect-ratio)

This resamples the image to a new width and height, ignoring the original image aspect ratio.

```
use AppUtils\ImageHelper\ImageFiles\FileTypes\JPGFile;

JPGFile::factory('image.jpg')
    ->resample('resized.jpg', 200, 400);
```

### Displaying an image in the browser

[](#displaying-an-image-in-the-browser)

Send an image file to the browser for display. This automatically sets the correct headers for the image format.

```
use AppUtils\ImageHelper\ImageFiles\FileTypes\JPGFile;

JPGFile::factory('image.jpg')
    ->send('optional-name.jpg');

// You must manually exit the script after sending the image.
exit;
```

### Trigger the download of an image

[](#trigger-the-download-of-an-image)

This will send the image to the browser, and force it to treat it as a download and show the download dialog.

```
use AppUtils\ImageHelper\ImageFiles\FileTypes\JPGFile;

JPGFile::factory('image.jpg')
    // Set the second parameter to true to force the download.
    ->send('optional-name.jpg', true);

// You must manually exit the script after sending the image.
exit;
```

Advanced editing
----------------

[](#advanced-editing)

### The ImageHelper class

[](#the-imagehelper-class)

While the image file classes are practical for simple operations, the `ImageHelper` class provides more advanced editing capabilities, as well as combining multiple operations in a single chain.

### Creating an instance

[](#creating-an-instance)

```
use AppUtils\ImageHelper;
use AppUtils\ImageHelper\ImageFiles\FileTypes\JPGFile;

// From a file path
$helper = ImageHelper::createFromFile('image.jpg');

// From an image class
$helper = JPGFile::factory('image.jpg')->createImageHelper();

// From a GD resource
$resource = imagecreatefromjpeg('image.jpg');
$helper = ImageHelper::createFromResource($resource);

// New blank image
$helper = ImageHelper::createNew(200, 100);
```

### Examples

[](#examples)

#### Resampling an image

[](#resampling-an-image)

```
use AppUtils\ImageHelper;

ImageHelper::createFromFile('image.jpg')
    ->resampleByWidth(200)
    ->save('resized.jpg');
```

#### Sharpening an image

[](#sharpening-an-image)

This will sharpen the image by the given percentage.

> NOTE: For best results, do some testing to find the optimal sharpening percentage for your target image size.

```
use AppUtils\ImageHelper;

ImageHelper::createFromFile('image.jpg')
    ->resampleByWidth(200)
    ->sharpen(50)
    ->setQuality(80)
    ->save('sharpened.jpg');
```

#### Get image dimensions (including SVG)

[](#get-image-dimensions-including-svg)

```
use AppUtils\ImageHelper;

$size = ImageHelper::getImageSize('image.jpg');

echo $size->toReadableString();
```

### Freeing resources

[](#freeing-resources)

When you're done editing, call the `dispose()` method to release file handles and memory resources. By default, the `save()` method will automatically do this for you. In case you're not saving the image, you should call `dispose()` manually.

```
use AppUtils\ImageHelper;

$average = ImageHelper::createFromFile('image.jpg')
    ->calcAverageColorRGB();

// Not needed anymore? Free up resources.
$helper->dispose();
```

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance41

Moderate activity, may be stable

Popularity31

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity45

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

Total

4

Last Release

490d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8895528?v=4)[Mistralys](/maintainers/Mistralys)[@Mistralys](https://github.com/Mistralys)

---

Top Contributors

[![Mistralys](https://avatars.githubusercontent.com/u/8895528?v=4)](https://github.com/Mistralys "Mistralys (32 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/mistralys-application-utils-image/health.svg)

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

###  Alternatives

[milon/barcode

Barcode generator like Qr Code, PDF417, C39, C39+, C39E, C39E+, C93, S25, S25+, I25, I25+, C128, C128A, C128B, C128C, 2-Digits UPC-Based Extention, 5-Digits UPC-Based Extention, EAN 8, EAN 13, UPC-A, UPC-E, MSI (Variation of Plessey code)

1.5k13.3M39](/packages/milon-barcode)[bkwld/croppa

Image thumbnail creation through specially formatted URLs for Laravel

510496.0k23](/packages/bkwld-croppa)[goat1000/svggraph

Generates SVG graphs

132849.6k3](/packages/goat1000-svggraph)[cohensive/embed

Media Embed (for Laravel or as a standalone).

120370.4k](/packages/cohensive-embed)[netresearch/rte-ckeditor-image

Image support in CKEditor for the TYPO3 ecosystem - by Netresearch

63991.3k4](/packages/netresearch-rte-ckeditor-image)[humanmade/tachyon-plugin

Rewrites WordPress image URLs to use Tachyon

87338.5k2](/packages/humanmade-tachyon-plugin)

PHPackages © 2026

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