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

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

thegrommet/image-resizer
========================

A PHP library for resizing images

v1.2.0(4y ago)112.4k[1 PRs](https://github.com/thegrommet/image-resizer/pulls)MITPHPPHP ^7.4 || ^8.0CI failing

Since Aug 12Pushed 3mo ago11 watchersCompare

[ Source](https://github.com/thegrommet/image-resizer)[ Packagist](https://packagist.org/packages/thegrommet/image-resizer)[ RSS](/packages/thegrommet-image-resizer/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (6)Dependencies (4)Versions (12)Used By (0)

Grommet Image Resizer
=====================

[](#grommet-image-resizer)

A PHP library for resizing images

### Build status

[](#build-status)

[![CircleCI](https://camo.githubusercontent.com/4f1bad6e5fcf4c7050390d7508b33ab376adee51fbed631c1fd185ea100184ae/68747470733a2f2f636972636c6563692e636f6d2f67682f74686567726f6d6d65742f696d6167652d726573697a65722e7376673f7374796c653d737667)](https://circleci.com/gh/thegrommet/image-resizer)

Usage
-----

[](#usage)

### Resizing

[](#resizing)

```
$resizer = new \Grommet\ImageResizer\Resizer('/path/to/images', '/path/to/save');
$newPath = $resizer->resize('in.jpg', 'out.jpg', ['strategy' => 'fit', 'width' => 100]);
// $newPath = '/path/to/save/out.jpg'
```

### Generating URLs to assets

[](#generating-urls-to-assets)

```
$urlGen = new \Grommet\ImageResizer\UrlGenerator('https://cdn.site.com/media');
$url = $urlGen->imageUrl('i/image.jpg', ['strategy' => 'fit', 'width' => 100]);
// $url = 'https://cdn.site.com/media/fit_w-100/i/image.jpg'
```

### Resize presets

[](#resize-presets)

```
$presets = [
    'small' => [
        'width' => 293,
        'height' => 219
    ],
    'large' => [
        'strategy' = 'crop',
        'width' => 500,
        'height' => 500
    ]
];

/* urls */
$urlGen = new \Grommet\ImageResizer\UrlGenerator('https://cdn.site.com/media', $presets);
$url = $urlGen->imageUrl('i/image.jpg', ['size' => 'small']);
// $url = 'https://cdn.site.com/media/fit_w-293_h-219/i/image.jpg'

/* files */
$resizer = new \Grommet\ImageResizer\PresetResizer(
    '/path/to/images',
    '/path/to/save',
    $presets
);
$newPath = $resizer->resize('image.jpg', 'large');
// $newPath = '/path/to/save/crop_w-500_h-500_m-c/image.jpg'
```

### Resizing service

[](#resizing-service)

```
$urlResizer = new \Grommet\ImageResizer\UrlResizer(
    '/path/to/images',
    '/path/to/save',
    'https://cdn.site.com/media'
);

// incoming request for a resized image
$url = 'https://cdn.site.com/media/fit_w-100/i/image.jpg';
$newPath = $urlResizer->resize($url);
// $newPath = '/path/to/save/fit_w-100/i/image.jpg'

header('Content-Type: image/jpeg');
$resource = imagecreatefromjpeg($newPath);
imagejpeg($resource);  // output to browser
imagedestroy($resource);
```

Resize Strategies
-----------------

[](#resize-strategies)

StrategyDescription`exact`Resize to exact width and height. Aspect ratio will not be maintained.`fit`Resize to fit the specified width and height, maintaining aspect ratio.`fill`Resize to fit the specified bounds while maintaining the aspect ratio. Image will be padded with empty space with color in `background`.`crop`Crop an image to the exact size specified. Optionally specify `cropMode`.`optimize`Save the image at the existing dimensions while reducing quality and file size. Optionally specify `quality`.Resize Adapters
---------------

[](#resize-adapters)

By default, the resizer will use PHP's GD2 functions to resize the images. You may specify a different image resize adapter to and offload that work to a 3rd party.

### Kraken.io

[](#krakenio)

Use Kraken's image resizing service once you have an account and API access:

```
$resizer = new \Grommet\ImageResizer\Resizer(
    '/path/to/images',
    '/path/to/save',
    'kraken',
    ['api-key', 'api-secret']
);
$newPath = $resizer->resize('in.jpg', 'out.jpg', ['strategy' => 'fit', 'w' => 100, 'h' => 50]);
// $newPath = '/path/to/save/out.jpg'
```

Running tests
-------------

[](#running-tests)

```
composer test
```

Code style &amp; fix
--------------------

[](#code-style--fix)

```
# sniff src folder
composer fmt-check

# fix src folder
composer fmt
```

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance53

Moderate activity, may be stable

Popularity22

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 61.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 ~155 days

Recently: every ~226 days

Total

7

Last Release

1538d ago

Major Versions

v0.6.1 → v1.02019-09-10

PHP version history (3 changes)v0.6PHP ^7.1

v1.1.0PHP ^7.3

v1.2.0PHP ^7.4 || ^8.0

### Community

Maintainers

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

---

Top Contributors

[![tmannherz](https://avatars.githubusercontent.com/u/533798?v=4)](https://github.com/tmannherz "tmannherz (11 commits)")[![arthurpro](https://avatars.githubusercontent.com/u/8511470?v=4)](https://github.com/arthurpro "arthurpro (7 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[spacecatninja/imager-x

Ninja powered image transforms.

29390.0k23](/packages/spacecatninja-imager-x)[goat1000/svggraph

Generates SVG graphs

132849.6k3](/packages/goat1000-svggraph)[ambroisemaupate/intervention-request

A customizable Intervention Image wrapper to use image simple re-sampling features over urls and a configurable cache.

4242.4k2](/packages/ambroisemaupate-intervention-request)[contao/image

Contao image library

131.7M9](/packages/contao-image)[intervention/image-driver-vips

libvips driver for Intervention Image

4495.5k6](/packages/intervention-image-driver-vips)[yncki/php-fast-image-compare

Image Comparer with different aspect ratios and sizes. Can extract duplicate and unique images in directory and much more.

1869.4k](/packages/yncki-php-fast-image-compare)

PHPackages © 2026

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