PHPackages                             sirv/sirv-image - 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. sirv/sirv-image

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

sirv/sirv-image
===============

Official PHP SDK for the Sirv dynamic imaging API. This SDK provides a simple way to request any modified image (dimensions, format, quality, sharpen, crop, watermark etc.) using the 100+ image transformation options in Sirv's image optimization service.

2.0.0(3mo ago)00MITPHPPHP &gt;=7.4CI passing

Since Mar 25Pushed 3mo agoCompare

[ Source](https://github.com/sirv/sirv-image-php)[ Packagist](https://packagist.org/packages/sirv/sirv-image)[ Docs](https://sirv.github.io/sirv-image-php/)[ RSS](/packages/sirv-sirv-image/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

Sirv Image Transformation - PHP
===============================

[](#sirv-image-transformation---php)

A fluent URL builder for [Sirv](https://sirv.com) dynamic image transformations. Build transformed image URLs with an intuitive, chainable API — no API credentials required.

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

[](#installation)

```
composer require sirv/sirv-image
```

Quick Start
-----------

[](#quick-start)

```
use Sirv\SirvImage;

$url = (new SirvImage('https://demo.sirv.com/image.jpg'))
    ->resize(300, 200)
    ->format('webp')
    ->quality(80)
    ->toUrl();

// https://demo.sirv.com/image.jpg?w=300&h=200&format=webp&q=80
```

Constructor
-----------

[](#constructor)

```
// Full image URL
new SirvImage('https://demo.sirv.com/image.jpg');

// Base URL + path
new SirvImage('https://demo.sirv.com', '/image.jpg');
```

API Reference
-------------

[](#api-reference)

All methods return `$this` for chaining. Call `->toUrl()` to get the final URL. Casting to string also works.

### Resize

[](#resize)

MethodParametersDescription`resize($width, $height, $option)``int|null, int|null, string|null`Resize with optional scale option`width($w)``int`Set width`height($h)``int`Set height`scaleByLongest($s)``int`Resize by longest dimension`thumbnail($size = 256)``int`Create square thumbnail### Crop

[](#crop)

MethodParametersDescription`crop($w, $h, $x, $y, $type, $padW, $padH)`all nullableCrop image`clipPath($name)``string`Apply clipping path### Rotation

[](#rotation)

MethodDescription`rotate($degrees)`Rotate (-180 to 180)`flip()`Flip vertically`flop()`Flip horizontally### Format &amp; Quality

[](#format--quality)

MethodParametersDescription`format($fmt)``string`Output format`quality($q)``int`JPEG quality (0-100)`webpFallback($fmt)``string`WebP fallback`subsampling($value)``string`Chroma subsampling`pngOptimize($enabled = true)``bool`PNG optimization`gifLossy($level)``int`GIF lossy compression### Color Adjustments

[](#color-adjustments)

`brightness($v)`, `contrast($v)`, `exposure($v)`, `hue($v)`, `saturation($v)`, `lightness($v)`, `shadows($v)`, `highlights($v)` — all accept `int` (-100 to 100).

`grayscale()`, `colorLevel($black, $white)`, `histogram($channel)`

### Color Effects

[](#color-effects)

MethodParametersDescription`colorize($color, $opacity)``string, int`Color overlay`colortone($preset)``string`Preset colortone`colortone(null, $options)``array`Custom colortone with color, level, mode### Effects

[](#effects)

`blur($v)`, `sharpen($v)`, `vignette($value, $color)`, `opacity($v)`

### Text Overlay

[](#text-overlay)

```
->text('Hello', [
    'fontSize' => 32,
    'fontFamily' => 'Arial',
    'fontStyle' => 'italic',
    'fontWeight' => 700,
    'color' => 'white',
    'opacity' => 80,
    'outlineWidth' => 2,
    'outlineColor' => 'black',
    'backgroundColor' => 'red',
    'backgroundOpacity' => 50,
    'align' => 'center',
    'position' => 'center',
    'positionX' => 10,
    'positionY' => 20,
    'positionGravity' => 'northwest',
])
```

### Watermark

[](#watermark)

```
->watermark('/logo.png', [
    'position' => 'southeast',
    'opacity' => 50,
    'scaleWidth' => '20%',
    'scaleOption' => 'fit',
    'rotate' => 45,
    'layer' => 'front',
])
```

### Canvas &amp; Frame

[](#canvas--frame)

```
->canvas(['width' => 800, 'height' => 600, 'color' => 'ffffff',
          'aspectRatio' => '16:9', 'borderWidth' => 10])
->frame(['style' => 'solid', 'color' => '333', 'width' => 5,
         'rimColor' => 'gold', 'rimWidth' => 2])
```

### Other

[](#other)

MethodDescription`page($num)`PDF page`profile($name)`Saved profileExamples
--------

[](#examples)

### E-commerce Product

[](#e-commerce-product)

```
$url = (new SirvImage('https://demo.sirv.com/products/shoe.jpg'))
    ->resize(800, 600, 'fill')
    ->format('webp')
    ->quality(85)
    ->watermark('/brand-logo.png', ['position' => 'southeast', 'opacity' => 30])
    ->toUrl();
```

### Vintage Effect

[](#vintage-effect)

```
$url = (new SirvImage('https://demo.sirv.com/photo.jpg'))
    ->colortone('sepia')
    ->vignette(40)
    ->frame(['style' => 'solid', 'color' => 'f5e6d3', 'width' => 20])
    ->toUrl();
```

Testing
-------

[](#testing)

```
./vendor/bin/phpunit tests/
```

License
-------

[](#license)

MIT

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance82

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity34

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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

91d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/11ce78626396f6fdbe974db2dffbb014678d9ffb7d75668d8b508149c4899d8b?d=identicon)[sirv](/maintainers/sirv)

---

Top Contributors

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

---

Tags

imageimage processinggalleryresponsivecdnsrcsetimage-optimizationzoomimage transformation3603dspinsirv

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sirv-sirv-image/health.svg)

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

###  Alternatives

[spacecatninja/imager-x

Ninja powered image transforms.

29399.9k34](/packages/spacecatninja-imager-x)[sitegeist/sms-responsive-images

Provides ViewHelpers and configuration to render valid responsive images based on TYPO3's image cropping tool.

34508.8k3](/packages/sitegeist-sms-responsive-images)[heyday/silverstripe-responsive-images

Configure and send a series of image size options to the client without loading any resources until a media query can be executed.

5389.1k6](/packages/heyday-silverstripe-responsive-images)[otisz/laravel-imgix

1419.4k](/packages/otisz-laravel-imgix)[urlbox/screenshots

Use urlbox to easily generate website thumbnail screenshots from a URL

11258.7k](/packages/urlbox-screenshots)[somehow-digital/typo3-media-processing

Media Processing

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

PHPackages © 2026

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