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

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

hosmelq/imgproxy
================

Build imgproxy URLs in PHP with optional encryption and signing.

v1.0.0(5mo ago)02.9k↓44.8%1MITPHPPHP ^8.3CI passing

Since Dec 3Pushed 5mo agoCompare

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

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

imgproxy PHP
============

[](#imgproxy-php)

Build imgproxy URLs in PHP with optional encryption and signing.

Introduction
------------

[](#introduction)

This package generates imgproxy URLs with every documented option (free and pro) and signs requests when you provide a key/salt pair. Long option names are emitted by default, and you can switch to the short aliases that imgproxy supports.

```
use HosmelQ\Imgproxy\Imgproxy;
use HosmelQ\Imgproxy\ResizingType;

$url = Imgproxy::create(baseUrl: 'https://imgproxy.example.com')
    ->format(extension: 'png')
    ->resize(type: ResizingType::Fit, width: 1200, height: 630)
    ->build(sourceUrl: 'https://example.com/image.jpg');
```

Requirements
------------

[](#requirements)

- PHP 8.3+
- OpenSSL extension (for source encryption)

Installation &amp; setup
------------------------

[](#installation--setup)

Install via Composer:

```
composer require hosmelq/imgproxy
```

Basic usage
-----------

[](#basic-usage)

### Getting started

[](#getting-started)

Create a builder with your base URL and optional signing key/salt. Configure processing options fluently, then build the URL for a source image.

```
use HosmelQ\Imgproxy\Imgproxy;
use HosmelQ\Imgproxy\ResizingType;
use HosmelQ\Imgproxy\Support\Gravity;

$builder = Imgproxy::create(
    baseUrl: 'https://imgproxy.example.com',
    key: 'b397f17682dea6270ac06941ca1e3f0f',
    salt: '68de0f586bdb701cf2458565bf5a6aec'
);

$url = $builder
    ->format(extension: 'png')
    ->gravity(gravity: Gravity::smart())
    ->quality(quality: 80)
    ->resize(type: ResizingType::Fit, width: 1200, height: 630)
    ->build(sourceUrl: 'https://example.com/product.jpg');
```

Switch to short option names if you want more compact URLs:

```
$shortUrl = $builder
    ->useShortOptions()
    ->build(sourceUrl: 'https://example.com/product.jpg');
```

### Source encoding choices

[](#source-encoding-choices)

Base64 is the default. You can output plain or encrypted sources when needed:

```
use HosmelQ\Imgproxy\Imgproxy;
use HosmelQ\Imgproxy\SourceEncoding;

// Plain source (no signature if key/salt are omitted)
$plainUrl = Imgproxy::create(baseUrl: 'https://imgproxy.example.com')
    ->format(extension: 'png')
    ->usePlainSource()
    ->build(sourceUrl: 'https://example.com/product.jpg');

// Encrypted source (pro)
$encryptedUrl = Imgproxy::create(baseUrl: 'https://imgproxy.example.com')
    ->format(extension: 'png')
    ->useEncryptedSource()
    ->withEncryptionKey(key: '1eb5b0e971ad7f45324c1bb15c947cb207c43152fa5c6c7f35c4f36e0c18e0f1')
    ->build(sourceUrl: 'https://example.com/private.jpg', encoding: SourceEncoding::Encrypted);
```

### Signing and truncation

[](#signing-and-truncation)

Provide both key and salt to enable signing, optionally truncate the signature to match your imgproxy config:

```
use HosmelQ\Imgproxy\Imgproxy;

$signed = Imgproxy::create(
    baseUrl: 'https://imgproxy.example.com',
    key: 'b397f17682dea6270ac06941ca1e3f0f',
    salt: '68de0f586bdb701cf2458565bf5a6aec',
    signatureSize: 12,
)
    ->format(extension: 'png')
    ->build(sourceUrl: 'https://example.com/product.jpg');
```

Advanced usage
--------------

[](#advanced-usage)

### Custom IV generator for encrypted sources

[](#custom-iv-generator-for-encrypted-sources)

Pass your own IV generator to `withEncryptionKey` when you need a specific IV strategy (for example, to align with another language implementation):

```
use HosmelQ\Imgproxy\Imgproxy;

$url = Imgproxy::create(baseUrl: 'https://imgproxy.example.com')
    ->format(extension: 'png')
    ->useEncryptedSource()
    ->withEncryptionKey(
        key: '1eb5b0e971ad7f45324c1bb15c947cb207c43152fa5c6c7f35c4f36e0f199a',
        ivGenerator: fn (): string => random_bytes(16)
    )
    ->build(sourceUrl: 'https://example.com/private.jpg');
```

Testing
-------

[](#testing)

```
composer test
```

Deployments
-----------

[](#deployments)

Want a ready-to-run imgproxy instance? Use the Railway template:

[![Deploy on Railway](https://camo.githubusercontent.com/88cb27bf937b98276737ba7888269a1bc9495d8670f63e1acc908b3442841114/68747470733a2f2f7261696c7761792e636f6d2f627574746f6e2e737667)](https://railway.com/deploy/imgproxy?referralCode=i6jUWN&utm_medium=integration&utm_source=template&utm_campaign=generic)

Changelog
---------

[](#changelog)

Please see [CHANGELOG.md](CHANGELOG.md) for recent changes.

Credits
-------

[](#credits)

- [Hosmel Quintana](https://github.com/hosmelq)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance70

Regular maintenance activity

Popularity23

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity50

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

Unknown

Total

1

Last Release

167d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/97fd048037c6d5ccfeebf11961838d5db2dca1baca14fefa373230b301389a03?d=identicon)[hosmelq](/maintainers/hosmelq)

---

Top Contributors

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

---

Tags

encryptionimage-processingimage-transformsimgproxyimgproxy-phpphpsigned-urlsurl-builderphpencryptionimage processingurl builderimgproxysigned-urlsimgproxy-phpimage-transforms

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[dereuromark/media-embed

A PHP library to deal with all those media services around, parsing their URLs and embedding their audio/video content in websites.

182530.3k11](/packages/dereuromark-media-embed)[tomatophp/filament-media-manager

Manage your media files using spatie media library with easy to use GUI for FilamentPHP

14543.9k3](/packages/tomatophp-filament-media-manager)[batdan/midjourney-api-php

Generate images Midjourney (Discord API). URLs in prompt accepted

222.2k](/packages/batdan-midjourney-api-php)[nikkanetiya/laravel-color-palette

Laravel Wrapper for `ksubileau/color-thief-php`. Grabs the dominant color or a representative color palette from an image. Uses PHP and GD or Imagick.

3312.6k](/packages/nikkanetiya-laravel-color-palette)[kiwilan/php-audio

PHP package to parse and update audio files metadata, with `JamesHeinrich/getID3`.

3012.6k1](/packages/kiwilan-php-audio)[automattic/wistia-php

PHP wrapper for Wistia API

1431.9k](/packages/automattic-wistia-php)

PHPackages © 2026

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