PHPackages                             xiidea/easy-imgproxy-bundle - 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. xiidea/easy-imgproxy-bundle

ActiveSymfony-bundle

xiidea/easy-imgproxy-bundle
===========================

Symfony Bundle for generating secure, signed URLs for imgproxy service

00PHPCI passing

Since Apr 9Pushed 3w agoCompare

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

READMEChangelog (1)DependenciesVersions (1)Used By (0)

Easy ImgProxy Bundle
====================

[](#easy-imgproxy-bundle)

[![Tests](https://github.com/xiidea/easy-imgproxy/actions/workflows/tests.yml/badge.svg)](https://github.com/xiidea/easy-imgproxy/actions/workflows/tests.yml)[![codecov](https://camo.githubusercontent.com/ae0cc8e3ccce6fbe82f9cdf4eef16931d1af1b478eb5e3c90f78f5b5fd4e2ece/68747470733a2f2f636f6465636f762e696f2f67682f7869696465612f656173792d696d6770726f78792f67726170682f62616467652e737667)](https://codecov.io/gh/xiidea/easy-imgproxy)

A Symfony Bundle for generating secure, signed URLs for the [imgproxy](https://imgproxy.net) service.

Features
--------

[](#features)

- Clean, fluent Builder pattern API
- HMAC-SHA256 signing with URL-safe Base64 encoding
- Full Symfony integration with Dependency Injection
- Comprehensive test coverage
- PHP 8.1+ support

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

[](#installation)

```
composer require xiidea/easy-imgproxy-bundle
```

Configuration
-------------

[](#configuration)

Add the bundle to your `config/bundles.php`:

```
return [
    // ...
    Xiidea\EasyImgProxyBundle\XiideaEasyImgProxyBundle::class => ['all' => true],
];
```

Create `config/packages/xiidea_easy_img_proxy.yaml`:

```
xiidea_easy_img_proxy:
  key: '%env(IMGPROXY_KEY)%'
  salt: '%env(IMGPROXY_SALT)%'
  base_url: '%env(IMGPROXY_BASE_URL)%'
```

Add to `.env`:

```
# Hex-encoded 32-byte key
IMGPROXY_KEY=0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef

# Hex-encoded 16-byte salt
IMGPROXY_SALT=0123456789abcdef0123456789abcdef

# imgproxy service URL
IMGPROXY_BASE_URL=http://localhost:8080
```

Usage
-----

[](#usage)

### Using the Builder Pattern

[](#using-the-builder-pattern)

```
use Xiidea\EasyImgProxyBundle\Service\ImgProxyUrlGenerator;

// Inject the service
public function __construct(ImgProxyUrlGenerator $generator)
{
    $this->generator = $generator;
}

// Build a URL
$url = $this->generator->builder()
    ->withImageUrl('https://example.com/image.jpg')
    ->withWidth(200)
    ->withHeight(300)
    ->withQuality(80)
    ->withExtension('webp')
    ->build();
```

### Using Inline Generation

[](#using-inline-generation)

```
$url = $this->generator->generate(
    'https://example.com/image.jpg',
    [
        'width' => 200,
        'height' => 300,
        'quality' => 80,
        'gravity' => 'center',
    ],
    'webp' // optional extension
);
```

### Available Options

[](#available-options)

**Dimension Options:**

- `withWidth(int)` - Image width in pixels
- `withHeight(int)` - Image height in pixels
- `withResizing(string)` - Resizing type: `fit`, `fill`, `auto`, `force`
- `withGravity(string)` - Gravity: `center`, `north`, `south`, `east`, `west`, etc.
- `withQuality(int)` - JPEG quality: 0-100

**Format Option:**

- `withExtension(string)` - Output format: `webp`, `png`, `jpg`, `gif`, etc.

**Custom Options:**

- `withOption(string $key, mixed $value)` - Add any custom processing option

Presets
-------

[](#presets)

The bundle supports two types of presets:

### 1. Custom Presets (Defined in Configuration)

[](#1-custom-presets-defined-in-configuration)

Define reusable configurations in `config/packages/xiidea_easy_img_proxy.yaml`:

```
xiidea_easy_img_proxy:
  key: '%env(IMGPROXY_KEY)%'
  salt: '%env(IMGPROXY_SALT)%'
  base_url: '%env(IMGPROXY_BASE_URL)%'

  presets:
    thumbnail:
      options:
        width: 200
        height: 200
        resizing_type: fill
        gravity: center
        quality: 85
      extension: webp

    hero:
      options:
        width: 1200
        height: 400
        resizing_type: fill
        quality: 90
      extension: jpg

    product:
      options:
        width: 600
        quality: 90
```

Use custom presets in your code:

```
// Apply a single preset
$url = $this->generator->builder()
    ->withImageUrl('https://example.com/image.jpg')
    ->withPreset('thumbnail')
    ->build();

// Apply multiple presets (later ones override earlier ones)
$url = $this->generator->builder()
    ->withImageUrl('https://example.com/image.jpg')
    ->withPresets(['product', 'quality'])
    ->build();

// Override preset options with explicit values
$url = $this->generator->builder()
    ->withImageUrl('https://example.com/image.jpg')
    ->withPreset('thumbnail')
    ->withQuality(95)  // Overrides preset quality
    ->withExtension('png')  // Overrides preset extension
    ->build();
```

### 2. Server Presets (Defined in imgproxy)

[](#2-server-presets-defined-in-imgproxy)

Apply presets defined on the imgproxy server:

```
// Apply a single server preset
$url = $this->generator->builder()
    ->withImageUrl('https://example.com/image.jpg')
    ->withServerPreset('blurry')
    ->build();

// Apply server preset with parameters
$url = $this->generator->builder()
    ->withImageUrl('https://example.com/image.jpg')
    ->withServerPreset('blur:strong')
    ->build();

// Apply multiple server presets
$url = $this->generator->builder()
    ->withImageUrl('https://example.com/image.jpg')
    ->withServerPresets(['sharpen', 'quality:high'])
    ->build();
```

### Combining Custom and Server Presets

[](#combining-custom-and-server-presets)

Both preset types can be used together:

```
$url = $this->generator->builder()
    ->withImageUrl('https://example.com/image.jpg')
    ->withServerPreset('blur')          // imgproxy server preset
    ->withPreset('product')             // custom preset
    ->withQuality(90)                   // explicit option (highest priority)
    ->build();
```

**Priority Order** (highest to lowest):

1. Explicitly set options (e.g., `withWidth(300)`)
2. Custom preset options
3. Server presets (imgproxy-side)

### URL Structure

[](#url-structure)

Generated URLs follow the imgproxy format:

```
{BASE_URL}/{SIGNATURE}/{PROCESSING_PATH}/{IMAGE_URL}

```

Example:

```
http://localhost:8080/UtBg7s3YMkw5-gP...bQ/width/200/height/300/format/webp/https://example.com/image.jpg

```

Testing
-------

[](#testing)

Run the test suite:

```
vendor/bin/phpunit
```

Security
--------

[](#security)

The bundle correctly implements imgproxy's signing specification:

1. Processes all options into a URL path
2. Signs the path using HMAC-SHA256 with the provided key
3. Prepends the salt to the signature
4. Encodes using URL-safe Base64 without padding
5. Builds the final signed URL

License
-------

[](#license)

MIT

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance62

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/0f7cc5359750f4e8cf854ddd35f5d9f752eb026d2f383e49a6ba2b4755db4da3?d=identicon)[xiidea](/maintainers/xiidea)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/xiidea-easy-imgproxy-bundle/health.svg)

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

PHPackages © 2026

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