PHPackages                             fostercommerce/imgproxy - 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. fostercommerce/imgproxy

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

fostercommerce/imgproxy
=======================

A PHP library for generating imgproxy URLs with processing options.

1.0.3(1y ago)04.0k[1 issues](https://github.com/FosterCommerce/imgproxy-php/issues)1MITPHPPHP &gt;=8.2.0

Since Apr 21Pushed 5mo agoCompare

[ Source](https://github.com/FosterCommerce/imgproxy-php)[ Packagist](https://packagist.org/packages/fostercommerce/imgproxy)[ RSS](/packages/fostercommerce-imgproxy/feed)WikiDiscussions main Synced 1mo ago

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

Important

This package is no longer actively maintained. The Foster Commerce team has transitioned our projects over to [Small Pics](https://www.smallpics.io) using their official [PHP client](https://github.com/SmallPics/smallpics-php).

imgproxy-php
============

[](#imgproxy-php)

A PHP library for working with imgproxy. This package provides a simple way to build URLs with imgproxy processing options.

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

[](#installation)

```
composer require fostercommerce/imgproxy-php
```

Usage
-----

[](#usage)

### Creating Processing Options

[](#creating-processing-options)

```
use fostercommerce\imgproxy\Options;

// Create a new Options object
$options = new Options();

// Set options with individual setters
$options->setWidth(300)
    ->setHeight(400)
    ->setResizingType('fill')
    ->setGravity('sm');

// Get string representation for URL
echo $options->toString();
// Output: "width:300/height:400/resizing_type:fill/gravity:sm"

// Options object can also be used directly in a string context
echo $options;
// Output: "width:300/height:400/resizing_type:fill/gravity:sm"
```

### Alternative Initialization

[](#alternative-initialization)

It is possible to initialize the Options object with an associative array. The keys of the array are the option names and the values are the option values.

The values can either be a single value, an array of values, or an associative array of values.

- When a single value is used, it is passed as the first argument to the setter method.
- When an array of values is used, they are destructured as passed as arguments in order to the setter method.
- When an associative array is used, the key/value pairs are destructured and passed in as named arguments to the setter method.

```
// Create Options object with array of values
$options = new Options([
    'width' => 300,
    'height' => 400,
    'resize' => [
        'width' => 300,
        'height' => 400,
        'enlarge' => false,
        'resize_type' => 'fill',
    ],
    'gravity' => 'sm',
    'png_options' => [
        'interlaced' => true,
        'quantize' => false,
    ],
]);
```

### Building URLs

[](#building-urls)

```
use fostercommerce\imgproxy\Options;
use fostercommerce\imgproxy\UrlBuilder;

// Create options object
$options = new Options();
$options->setPreset('sharp')
    ->setResize('fill', 300, 400, false)
    // or
    ->setResize([
        'width' => 300,
        'height' => 400,
        'enlarge' => false,
        'resize_type' => 'fill',
    ])
    ->setGravity('sm')
    ->setQuality(80)
    ->setFormat('png');

// Create URL builder (without signing, with plain URLs)
$builder = new UrlBuilder('https://imgproxy.example.com', null, null, false);

// Build URL
$imageUrl = 'https://example.com/images/image.jpg';
$url = $builder->buildUrl($imageUrl, $options);

echo $url;
// Output: https://imgproxy.example.com/unsafe/preset:sharp/resize:fill:300:400:0/gravity:sm/quality:80/format:png/plain/https://example.com/images/image.jpg
```

### Encoded URLs

[](#encoded-urls)

```
use fostercommerce\imgproxy\Options;
use fostercommerce\imgproxy\UrlBuilder;

// Create options object
$options = new Options();
$options->setWidth(300)
    ->setHeight(400)
    ->setResizingType('fill');

// Create URL builder with base64 encoding (default behavior)
$builder = new UrlBuilder('https://imgproxy.example.com', null, null, true);

// Build URL with encoded source
$imageUrl = 'https://example.com/images/image.jpg';
$url = $builder->buildUrl($imageUrl, $options);

echo $url;
// Output: https://imgproxy.example.com/unsafe/width:300/height:400/resizing_type:fill/aHR0cHM6Ly9leGFtcGxlLmNvbS9pbWFnZXMvaW1hZ2UuanBn

// With extension
$url = $builder->buildUrl($imageUrl, $options, 'png');
echo $url;
// Output: https://imgproxy.example.com/unsafe/width:300/height:400/resizing_type:fill/aHR0cHM6Ly9leGFtcGxlLmNvbS9pbWFnZXMvaW1hZ2UuanBn.png
```

### Signed URLs

[](#signed-urls)

```
// Create URL builder with signing keys (using plain URLs)
$key = '0123456789abcdef0123456789abcdef';
$salt = 'fedcba9876543210fedcba9876543210';
$builder = new UrlBuilder('https://imgproxy.example.com', $key, $salt, false);

// Build signed URL
$imageUrl = 'https://example.com/images/image.jpg';
$url = $builder->buildUrl($imageUrl, $options, 'png');

echo $url;
// Output will include a signature: https://imgproxy.example.com/[signature]/preset:sharp/resize:fill:300:400:0/gravity:sm/quality:80/format:png/plain/https://example.com/images/image.jpg@png
```

### Signed and Encoded URLs

[](#signed-and-encoded-urls)

```
// Create URL builder with signing keys and base64 encoding
$key = '0123456789abcdef0123456789abcdef';
$salt = 'fedcba9876543210fedcba9876543210';
$builder = new UrlBuilder('https://imgproxy.example.com', $key, $salt, true);

// Build signed URL with encoded source
$imageUrl = 'https://example.com/images/image.jpg';
$url = $builder->buildUrl($imageUrl, $options);

echo $url;
// Output will include a signature: https://imgproxy.example.com/[signature]/preset:sharp/resize:fill:300:400:0/gravity:sm/quality:80/format:png/aHR0cHM6Ly9leGFtcGxlLmNvbS9pbWFnZXMvaW1hZ2UuanBn
```

Development
-----------

[](#development)

### Testing

[](#testing)

This package uses [Pest PHP](https://pestphp.com/) for testing. To run the tests:

```
composer test
```

or

```
vendor/bin/pest
```

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance62

Regular maintenance activity

Popularity16

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity52

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

Total

4

Last Release

385d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9ac5b96165dd51aed8f0b9ea079d5d5beeb430a915cd07d645db0a228b0ac3aa?d=identicon)[fostercommerce](/maintainers/fostercommerce)

---

Top Contributors

[![johnnynotsolucky](https://avatars.githubusercontent.com/u/4161106?v=4)](https://github.com/johnnynotsolucky "johnnynotsolucky (14 commits)")

---

Tags

phpimageprocessinglibraryimgproxy

###  Code Quality

TestsPest

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/fostercommerce-imgproxy/health.svg)

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

###  Alternatives

[talesoft/phim

An image and color manipulation and processing library for PHP

2958.2k](/packages/talesoft-phim)[lciolecki/php-image-optimizer

PHP image file optimizer (uses https://github.com/bensquire/php-image-optim)

347.4k](/packages/lciolecki-php-image-optimizer)[somehow-digital/typo3-media-processing

Media Processing

101.1k](/packages/somehow-digital-typo3-media-processing)

PHPackages © 2026

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