PHPackages                             laravel-enso/imagetransformer - 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. laravel-enso/imagetransformer

Abandoned → [laravel-enso/image-transformer](/?search=laravel-enso%2Fimage-transformer)Library[Image &amp; Media](/categories/media)

laravel-enso/imagetransformer
=============================

Image transformer dependency for Laravel Enso

2.5.4(2w ago)614.9k54MITPHPPHP ^8.0CI failing

Since Jul 3Pushed 2w ago4 watchersCompare

[ Source](https://github.com/laravel-enso/image-transformer)[ Packagist](https://packagist.org/packages/laravel-enso/imagetransformer)[ Docs](https://github.com/laravel-enso/image-transformer)[ RSS](/packages/laravel-enso-imagetransformer/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (6)Versions (59)Used By (4)

Image Transformer
=================

[](#image-transformer)

[![License](https://camo.githubusercontent.com/3270cd4bfb8f082a72827abb312d2a43252230bf6a2a6d5a7d586abbfd26c55b/68747470733a2f2f706f7365722e707567782e6f72672f6c61726176656c2d656e736f2f696d6167652d7472616e73666f726d65722f6c6963656e7365)](LICENSE)[![Stable](https://camo.githubusercontent.com/c1a38bf453986cf32cc3edffd69f83f74f5b7320f48275a4578b083cd275f61c/68747470733a2f2f706f7365722e707567782e6f72672f6c61726176656c2d656e736f2f696d6167652d7472616e73666f726d65722f76657273696f6e)](https://packagist.org/packages/laravel-enso/image-transformer)[![Downloads](https://camo.githubusercontent.com/cd5a37e11527d63e2cbaf8f14e640575232db7a15659ec43fdfc6ee6958ff111/68747470733a2f2f706f7365722e707567782e6f72672f6c61726176656c2d656e736f2f696d6167652d7472616e73666f726d65722f646f776e6c6f616473)](https://packagist.org/packages/laravel-enso/image-transformer)[![PHP](https://camo.githubusercontent.com/ef6afd4ccdaa708a9b1a0a353d6d03a13ca1f03887b8db701d4118dc30a6735a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d382e302532422d3737376262342e737667)](composer.json)[![Issues](https://camo.githubusercontent.com/e14406dc545d9a657e77f5900f310de933862171f875588b16dabc662effbcaa/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f6c61726176656c2d656e736f2f696d6167652d7472616e73666f726d65722e737667)](https://github.com/laravel-enso/image-transformer/issues)[![Merge Requests](https://camo.githubusercontent.com/c94876d0a0fd12bcaf9338a26b2d8c506a084ef1e70bd5adbde8d3afccbad87c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732d70722f6c61726176656c2d656e736f2f696d6167652d7472616e73666f726d65722e737667)](https://github.com/laravel-enso/image-transformer/pulls)

Description
-----------

[](#description)

Image Transformer provides a small service for validating, resizing, and optimizing uploaded images.

It wraps Intervention Image for resize operations and Spatie's image optimizer for post-processing, while enforcing a limited set of supported image mime types before any transformation is attempted.

The package is useful in upload flows where images should be normalized before storage, for example avatars, covers, gallery images, or document attachments that need size limits and optimization.

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

[](#installation)

Install the package:

```
composer require laravel-enso/image-transformer
```

The package relies on:

- `intervention/image-laravel` for reading and resizing images
- `spatie/laravel-image-optimizer` for optimization

To use resizing, the runtime must have at least one supported image extension installed:

- `gd`
- `imagick`

Features
--------

[](#features)

- Validates uploaded files before transformation.
- Supports `png`, `jpeg`, `gif`, and `webp` images.
- Optimizes images in place through Spatie's optimizer chain.
- Resizes images proportionally by width, by height, or by both through `resize()`.
- Prevents upsizing by only resizing when the original image is larger than the requested dimension.
- Saves transformations back to the original file path.

Usage
-----

[](#usage)

Create a transformer from an uploaded file:

```
use LaravelEnso\ImageTransformer\Services\ImageTransformer;

$transformer = new ImageTransformer($file);
```

Optimize the original file:

```
$transformer->optimize();
```

Resize proportionally to a maximum width:

```
$transformer->width(512);
```

Resize proportionally to a maximum height:

```
$transformer->height(512);
```

Apply both constraints in sequence:

```
$transformer->resize(1024, 768);
```

::: tip Tip The transformer edits the original file in place.

If you need to preserve the original upload, copy or move it before calling `optimize()`, `width()`, `height()`, or `resize()`. :::

API
---

[](#api)

### Service

[](#service)

`LaravelEnso\ImageTransformer\Services\ImageTransformer`

Constructor:

- `__construct(File $file)`

Public methods:

- `optimize(): self`
- `resize(int $width, int $height): self`
- `width(int $width): self`
- `height(int $height): self`

### Supported Mime Types

[](#supported-mime-types)

The service accepts:

- `image/png`
- `image/jpeg`
- `image/gif`
- `image/webp`

### Exceptions

[](#exceptions)

The package exposes:

- `LaravelEnso\ImageTransformer\Exceptions\File`
- `LaravelEnso\ImageTransformer\Exceptions\Dependency`

Scenarios covered:

- invalid uploaded file
- unsupported mime type
- missing `gd` / `imagick` extension when resizing

Depends On
----------

[](#depends-on)

Required Enso packages:

- [`laravel-enso/helpers`](https://docs.laravel-enso.com/backend/helpers.html) [↗](https://github.com/laravel-enso/helpers)

External dependencies:

- [`intervention/image-laravel`](https://github.com/Intervention/image-laravel) [↗](https://github.com/Intervention/image-laravel)
- [`spatie/laravel-image-optimizer`](https://github.com/spatie/laravel-image-optimizer) [↗](https://github.com/spatie/laravel-image-optimizer)

Contributions
-------------

[](#contributions)

are welcome. Pull requests are great, but issues are good too.

Thank you to all the people who already contributed to Enso!

###  Health Score

61

—

FairBetter than 99% of packages

Maintenance97

Actively maintained with recent releases

Popularity29

Limited adoption so far

Community25

Small or concentrated contributor base

Maturity82

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 57% 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 ~63 days

Recently: every ~8 days

Total

52

Last Release

16d ago

Major Versions

1.6.7 → 2.0.02020-06-26

PHP version history (4 changes)1.1.0PHP &gt;=7.1.0

1.6.0PHP &gt;=7.4.0

2.0.3PHP &gt;=8.0

2.2.0PHP ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/16073274?v=4)[Adrian Ocneanu](/maintainers/aocneanu)[@aocneanu](https://github.com/aocneanu)

---

Top Contributors

[![aocneanu](https://avatars.githubusercontent.com/u/16073274?v=4)](https://github.com/aocneanu "aocneanu (53 commits)")[![gandesc](https://avatars.githubusercontent.com/u/14071925?v=4)](https://github.com/gandesc "gandesc (26 commits)")[![AbdullahiAbdulkabir](https://avatars.githubusercontent.com/u/33360580?v=4)](https://github.com/AbdullahiAbdulkabir "AbdullahiAbdulkabir (3 commits)")[![raftx24](https://avatars.githubusercontent.com/u/10864136?v=4)](https://github.com/raftx24 "raftx24 (3 commits)")[![vmcvlad](https://avatars.githubusercontent.com/u/37445394?v=4)](https://github.com/vmcvlad "vmcvlad (3 commits)")[![GITmanuela](https://avatars.githubusercontent.com/u/44998004?v=4)](https://github.com/GITmanuela "GITmanuela (2 commits)")[![tedipop16](https://avatars.githubusercontent.com/u/71398467?v=4)](https://github.com/tedipop16 "tedipop16 (1 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (1 commits)")[![codacy-badger](https://avatars.githubusercontent.com/u/23704769?v=4)](https://github.com/codacy-badger "codacy-badger (1 commits)")

---

Tags

imageimage-optimisationimage-optimizationimage-resizeimage-resizerlaravellaravel-ensolaravel-imagelaravel-packagelaravelimage-optimizerlaravel-ensoimage-transformer

### Embed Badge

![Health badge](/badges/laravel-enso-imagetransformer/health.svg)

```
[![Health](https://phpackages.com/badges/laravel-enso-imagetransformer/health.svg)](https://phpackages.com/packages/laravel-enso-imagetransformer)
```

###  Alternatives

[intervention/image-laravel

Laravel Integration of Intervention Image

1496.5M102](/packages/intervention-image-laravel)[bkwld/croppa

Image thumbnail creation through specially formatted URLs for Laravel

510496.0k23](/packages/bkwld-croppa)[joshembling/image-optimizer

Optimize your Filament images before they reach your database.

111145.4k12](/packages/joshembling-image-optimizer)[mostafaznv/nova-ckeditor

CkEditor for Laravel Nova

57327.2k1](/packages/mostafaznv-nova-ckeditor)[classic-o/nova-media-library

Tool and field that will let you managing files and add them to the posts

154172.0k](/packages/classic-o-nova-media-library)[ace-of-aces/laravel-image-transform-url

Easy, URL-based image transformations inspired by Cloudflare Images.

1756.4k](/packages/ace-of-aces-laravel-image-transform-url)

PHPackages © 2026

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