PHPackages                             coderello/laravel-proximage - 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. coderello/laravel-proximage

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

coderello/laravel-proximage
===========================

Image proxy for Laravel.

2.1.0(5y ago)1588.4k13[1 issues](https://github.com/coderello/laravel-proximage/issues)1MITPHPPHP ^7.3|^8.0CI failing

Since Oct 10Pushed 2y ago1 watchersCompare

[ Source](https://github.com/coderello/laravel-proximage)[ Packagist](https://packagist.org/packages/coderello/laravel-proximage)[ RSS](/packages/coderello-laravel-proximage/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (15)Used By (1)

[![Proximage](https://camo.githubusercontent.com/9922df2c0e9528eeefa34b128da4a3ca3d1dc0e30b854f009eefb9741d24267c/68747470733a2f2f636f646572656c6c6f2e636f6d2f696d616765732f7061636b616765732f6c61726176656c2d70726f78696d6167652e706e67)](https://camo.githubusercontent.com/9922df2c0e9528eeefa34b128da4a3ca3d1dc0e30b854f009eefb9741d24267c/68747470733a2f2f636f646572656c6c6f2e636f6d2f696d616765732f7061636b616765732f6c61726176656c2d70726f78696d6167652e706e67)

**Proximage** is a handy package for proxying images through the [images.weserv.nl](https://images.weserv.nl) (free image cache &amp; resize service) with which you can greatly increase the performance of the site.

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

[](#installation)

You can install this package via composer using this command:

```
composer require coderello/laravel-proximage
```

The package will automatically register itself.

You can publish the config file with:

```
php artisan vendor:publish --tag="proximage-config"
```

Some important notes
--------------------

[](#some-important-notes)

> Images are **not** processed on your server (package generates a link to your image processed by a third-party service).

> The only way to specify an input image is to pass its **public link**.

Examples of use
---------------

[](#examples-of-use)

Only caching:

```
proximage($imageUrl)
  ->get();
```

Caching and resizing:

```
proximage($imageUrl)
  ->width(300)
  ->get();
```

Caching and cropping:

```
use Coderello\Proximage\Enums\Parameter;
```

```
proximage($imageUrl)
  ->crop(Parameter\CropAlignment::CENTER)
  ->transformation(Parameter\Transformation::SQUARE)
  ->get();
```

Basic methods
-------------

[](#basic-methods)

### url(?string $value): self

[](#urlstring-value-self)

Sets the link to your input image.

### parameter(string $name, $value): self

[](#parameterstring-name-value-self)

Sets the value of the parameter by its name.

You can find all existing parameter names in `Parameter` enum situated in `Coderello\Proximage\Enums` namespace.

> More handy way is to use methods for image manipulations which can be found in the section below.

### shouldProxy(Closure $shouldProxy): self

[](#shouldproxyclosure-shouldproxy-self)

Sets callback which detects if given image should be proxied. Callback receives `$url` as the first argument and should return `true` or `false`.

### template($template): self

[](#templatetemplate-self)

Applies template to the current `ImageProxy` instance.

**Accepts:**

- `string` (template class name)
- `object` (template instance)

**Out-of-the-box templates (you can find them in `Coderello\Proximage\Templates` namespace):**

- `AvatarTemplate`
- `DisableProxyingForLocalEnvironmentTemplate`

> Of course, you are not limited to these ones. You can create your own templates. Each one must implement `Template` contract situated in the `Coderello\Proximage\Contracts` namespace.

### get(): ?string

[](#get-string)

Returns URL of proxied image.

Methods for image manipulations
-------------------------------

[](#methods-for-image-manipulations)

### width($value): self

[](#widthvalue-self)

Sets the width of the image, in pixels.

### height($value): self

[](#heightvalue-self)

Sets the height of the image, in pixels.

### devicePixelRatio($value): self

[](#devicepixelratiovalue-self)

The device pixel ratio is used to easily convert between CSS pixels and device pixels. This makes it possible to display images at the correct pixel density on a variety of devices such as Apple devices with Retina Displays and Android devices. You must specify either a width, a height, or both for this parameter to work. Use values between `1` and `8`.

### transformation($value): self

[](#transformationvalue-self)

Controls how the image is fitted to its target dimensions.

Namespace of enum with possible values: `Coderello\Proximage\Enums\Parameter\Transformation`

**Accepts:**

- `Transformation::FIT`

Default. Resizes the image to fit within the width and height boundaries without cropping, distorting or altering the aspect ratio. Will not oversample the image if the requested size is larger than that of the original.

- `Transformation::FIT_UP`

Resizes the image to fit within the width and height boundaries without cropping, distorting or altering the aspect ratio. Will increase the size of the image if it is smaller than the output size.

- `Transformation::SQUARE`

Resizes the image to fill the width and height boundaries and crops any excess image data. The resulting image will match the width and height constraints without distorting the image. Will increase the size of the image if it is smaller than the output size.

- `Transformation::SQUARE_DOWN`

Resizes the image to fill the width and height boundaries and crops any excess image data. The resulting image will match the width and height constraints without distorting the image. Will not oversample the image if the requested size is larger than that of the original.

- `Transformation::ABSOLUTE`

Stretches the image to fit the constraining dimensions exactly. The resulting image will fill the dimensions, and will not maintain the aspect ratio of the input image.

- `Transformation::LETTERBOX`

Resizes the image to fit within the width and height boundaries without cropping or distorting the image, and the remaining space is filled with the background color. The resulting image will match the constraining dimensions.

### crop($value): self

[](#cropvalue-self)

Controls how the image is aligned.

Namespace of enum with possible values: `Coderello\Proximage\Enums\Parameter\CropAlignment`

**Crop position**

You can set where the image is cropped by adding a crop position. Only works when transformation is `Transformation::SQUARE`. Accepts `CropAlignment::TOP`, `CropAlignment::LEFT`, `CropAlignment::CENTER`, `CropAlignment::RIGHT` or `CropAlignment::BOTTOM`. Default is `CropAlignment::CENTER`.

**Crop focal point**

In addition to the crop position, you can be more specific about the exact crop position using a focal point. Only works when transformation is `Transformation::SQUARE`. This is defined using two offset percentages: `crop-x%-y%`.

**Smart crop**

Crops the image down to specific dimensions by removing boring parts. Only works when transformation is `Transformation::SQUARE`.

Accepts:

- `CropAlignment::ENTROPY`: focus on the region with the highest Shannon entropy.
- `CropAlignment::ATTENTION`: focus on the region with the highest luminance frequency, colour saturation and presence of skin tones.

**Manual crop**

Crops the image to specific dimensions after any other resize operations. Required format: `width,height,x,y`.

### mask($value): self

[](#maskvalue-self)

Sets the mask type from a predefined list of shapes.

Namespace of enum with possible values: `Coderello\Proximage\Enums\Parameter\Mask`

**Accepts:**

- `Mask::CIRCLE`
- `Mask::ELLIPSE`
- `Mask::TRIANLGE`
- `Mask::TRIANLGE_180`: triangle tilted upside down
- `Mask::PENTAGON`
- `Mask::PENTAGON_180`: pentagon tilted upside down
- `Mask::HEXAGON`
- `Mask::SQUARE`: square tilted 45 degrees
- `Mask::STAR`: 5-point star
- `Mask::HEART`

### maskTrim($value): self

[](#masktrimvalue-self)

Removes the remaining whitespace from the mask.

### maskBackground($value): self

[](#maskbackgroundvalue-self)

Sets the background color of the mask.

### orientation($value): self

[](#orientationvalue-self)

Rotates the image. Accepts `auto` or if an angle is specified, it is converted to a valid `90`/`180`/`270` degree rotation. For example, `-450` will produce a `270` degree rotation. Default is `auto`. The `auto` option uses Exif data to automatically orient images correctly.

### brightness($value): self

[](#brightnessvalue-self)

Adjusts the image brightness. Use values between `-100` and `+100`, where `0` represents no change.

### contrast($value): self

[](#contrastvalue-self)

Adjusts the image contrast. Use values between `-100` and `+100`, where `0` represents no change.

### gamma($value): self

[](#gammavalue-self)

Adjusts the image gamma. Use values between `1` and `3`. The default value is `2.2`, a suitable approximation for sRGB images.

### sharpen($value): self

[](#sharpenvalue-self)

Sharpen the image. Required format: `f,j,r`

**Arguments:**

- Flat `f` - Sharpening to apply to flat areas. (Default: 1.0)
- Jagged `j` - Sharpening to apply to jagged areas. (Default: 2.0)
- Radius `r` - Sharpening mask to apply in pixels, but comes at a performance cost. (optional)

### trim($value): self

[](#trimvalue-self)

Trim "boring" pixels from all edges that contain values within a similarity of the top-left pixel. Trimming occurs before any resize operation. Use values between `1` and `254` to define a tolerance level to trim away similar color values. You also can specify just &amp;trim, which defaults to a tolerance level of 10.

### background($value): self

[](#backgroundvalue-self)

Sets the background color of the image. Supports a variety of color formats. In addition to the 140 color names supported by all modern browsers (listed here), it also accepts hexadecimal RGB and RBG alpha formats.

**Hexadecimal**

- 3 digit RGB: `CCC`
- 4 digit ARGB (alpha): `5CCC`
- 6 digit RGB: `CCCCCC`
- 8 digit ARGB (alpha): `55CCCCCC`

### blur($value): self

[](#blurvalue-self)

Adds a blur effect to the image. Use values between `0` and `100`.

### filter($value): self

[](#filtervalue-self)

Applies a filter effect to the image.

Namespace of enum with possible values: `Coderello\Proximage\Enums\Parameter\Filter`

**Accepts:**

- `Filter::GREYSCALE`
- `Filter::SEPIA`
- `Filter::NEGATE`

### quality($value): self

[](#qualityvalue-self)

Defines the quality of the image. Use values between `0` and `100`. Defaults to `85`. Only relevant if the format is set to `Output::JPG`.

### output($value): self

[](#outputvalue-self)

Encodes the image to a specific format. If none is given, it will honor the origin image format.

Namespace of enum with possible values: `Coderello\Proximage\Enums\Parameter\Output`

**Accepts:**

- `Output::JPG`
- `Output::PNG`
- `Output::GIF`
- `Output::TIFF`
- `Output::WEBP`

### interlace($value): self

[](#interlacevalue-self)

Adds interlacing to GIF and PNG. JPEG's become progressive.

### encoding($value): self

[](#encodingvalue-self)

Encodes the image to be used directly in the src= of the ``-tag.

Namespace of enum with possible values: `Coderello\Proximage\Enums\Parameter\Encoding`

**Accepts:**

- `Encoding::BASE64`

### defaultImage($value): self

[](#defaultimagevalue-self)

If there is a problem loading an image, then a error is shown. However, there might be a need where instead of giving a broken image to the user, you want a default image to be delivered.

### page($value): self

[](#pagevalue-self)

To load a given page (for an PDF, TIFF and multi-size ICO file). The value is numbered from zero.

### filename($value): self

[](#filenamevalue-self)

To specify the filename returned in the `Content-Disposition` header. The filename must only contain alphanumeric characters.

Testing
-------

[](#testing)

You can run the tests with:

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity39

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity74

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

Recently: every ~157 days

Total

11

Last Release

1999d ago

Major Versions

0.6 → 1.0.02020-03-03

1.0.0 → 2.0.02020-09-09

PHP version history (4 changes)0.1.0PHP &gt;=7.1

1.0.0PHP ^7.2

2.0.0PHP ^7.3

2.1.0PHP ^7.3|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/c7123364682ac2202ac2f1174f28094efbf58ad38388888a983b76d52fec3c67?d=identicon)[coderello](/maintainers/coderello)

---

Top Contributors

[![hivokas](https://avatars.githubusercontent.com/u/22997803?v=4)](https://github.com/hivokas "hivokas (4 commits)")[![pactode](https://avatars.githubusercontent.com/u/5956778?v=4)](https://github.com/pactode "pactode (2 commits)")[![cyberhicham](https://avatars.githubusercontent.com/u/10002527?v=4)](https://github.com/cyberhicham "cyberhicham (1 commits)")

---

Tags

imagelaravelproximageproxy

### Embed Badge

![Health badge](/badges/coderello-laravel-proximage/health.svg)

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

###  Alternatives

[justbetter/statamic-image-optimize

Image optimization after upload

1315.2k](/packages/justbetter-statamic-image-optimize)[sukohi/surpass

A PHP package mainly developed for Laravel to manage uploading images using Ajax and displaying thumbnail.

283.8k](/packages/sukohi-surpass)

PHPackages © 2026

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