PHPackages                             tomkyle/yaphr - 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. tomkyle/yaphr

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

tomkyle/yaphr
=============

1.1.8(11y ago)127PHP

Since Oct 15Pushed 11y ago1 watchersCompare

[ Source](https://github.com/tomkyle/yaphr)[ Packagist](https://packagist.org/packages/tomkyle/yaphr)[ RSS](/packages/tomkyle-yaphr/feed)WikiDiscussions master Synced 6d ago

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

\#tomkyle\\yaphr

[![Build Status](https://camo.githubusercontent.com/a1d0a144ba82b064e3221f272826ea7c5f5e71f1d2207d3bf121656b0ccc7e80/68747470733a2f2f7472617669732d63692e6f72672f746f6d6b796c652f79617068722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/tomkyle/yaphr)

Yet Another Photo Resizer for JPG, PNG, GIF.
Resizing and cropping, crisp &amp; useful sharpening.

\##Installation

Yaphr has no dependencies so far, although but installing [Slim](https://github.com/codeguy/Slim) may be useful: Yaphr brings it own Slim Middleware for the most common resizing use cases. Install via Composer; add this to `composer.json`:

```
"require": {
	"tomkyle/yaphr": "~1.1"
}

```

\##Getting started

Yaphr comes with a convenience workflow that does most of the business for you:

```
use \tomkyle\yaphr\ImageFactory;
use \tomkyle\yaphr\Geometry\BoxFactory;
use \tomkyle\yaphr\Workflow;
use \SplFileInfo;

// YAPHR likes `SplFileInfo`
$source = new SplFileInfo( '../master/path/to/original.jpg' );
$output = new SplFileInfo( './path/to/resized.jpg' );

// Generate factories:
$image_factory = new ImageFactory;
$box_factory   = new BoxFactory;

// Grab your instances:
$image  = $image_factory->newInstance( $source );
$box    = $box_factory->newInstance( 300, 200, $image, 'crop');

// Convenience, convenience:
// Resize, Sharpen, Save to cache
// and Delivery to client in one step:
new Workflow( $image, $box, $output);
```

So the `Workflow` is your friend. This example shows what happens inside:

```
use \tomkyle\yaphr\Resize;
use \tomkyle\yaphr\Filters\SharpenImage;
use \tomkyle\yaphr\FileSystem\CreateCacheDir;
use \tomkyle\yaphr\FileSystem\SaveImage;
use \tomkyle\yaphr\FileSystem\DeliverImage;

// Create resized (cropped) image:
$resized = new Resize($image, $box);

// Make it nice and crisp:
new SharpenImage( $resized );

// Save to file cache:
new CreateCacheDir( $output, 0775 );
new SaveImage( $resized, $output, 85 );

// Send to client:
new DeliverImage( $output, "exit" );
```

\##Resize boxes Yaphr offers various resizing modes, all of them useful in different use cases. If you exactly know what you want, you may instantiate a concrete Box class; using the `BoxFactory` with string parameter gives more flexibility: Just pass desired `$width` and `$height`, your original `$image` and the box type.

**Crop** extracts as much as possible from the original that fits into the given width and height. Most useful for pictures with varying side ratios, e.g. in responsive context.

```
$exact = new CropBox( $width, $height, $image );
// same as
$exact = $box_factory->newInstance( $width, $height, $image, 'crop');
```

**Auto** makes portrait images `$height` pixels high, and landscape ones `$width` pixels, preserving side ratios. Perhaps the most classic resing mode.

```
$exact = new AutoBox( $width, $height, $image );
// same as
$exact = $box_factory->newInstance( $width, $height, $image, 'auto');
```

**Exact** fits the image in the given width and height, not preserving side ratio (i.e. the result may be distorted). Mostly not useful (except from, well, distorting).

```
$exact = new Box( $width, $height );
// same as
$exact = $box_factory->newInstance( $width, $height, $image, 'exact');
```

**Tall** resizes to the given height, regardless of the image width, but preserving side ratios. Useful for horizontal “same height” galleries or *Masonry galleries*.

```
$exact = new TallBox( $height, $image );
// same as
$exact = $box_factory->newInstance( $height, $height, $image, 'tall');
```

**Wide** resizes to the given width, regardless of the image height, but preserving side ratios. Useful for vertical “same width” galleries.

```
$exact = new WideBox( $width, $image );
// same as
$exact = $box_factory->newInstance( $width, $width, $image, 'wide');
```

\##Classes overview

\###Image classes

```
# Classes
use \tomkyle\yaphr\GifImage;
use \tomkyle\yaphr\JpegImage;
use \tomkyle\yaphr\PngImage;

# Abstracts and Interfaces
use \tomkyle\yaphr\ImageAbstract;
use \tomkyle\yaphr\ImageInterface;
use \tomkyle\yaphr\GifImageInterface;
use \tomkyle\yaphr\JpegImageInterface;
use \tomkyle\yaphr\PngImageInterface;
```

\###Business classes

```
# Classes
use \tomkyle\yaphr\ImageFactory;
use \tomkyle\yaphr\Workflow;
use \tomkyle\yaphr\Resize;
```

\###Geometry classes

```
# Boxes
use \tomkyle\yaphr\Geometry\Box;
use \tomkyle\yaphr\Geometry\BoxFactory;
use \tomkyle\yaphr\Geometry\AutoBox;
use \tomkyle\yaphr\Geometry\CropBox;
use \tomkyle\yaphr\Geometry\SquareBox;
use \tomkyle\yaphr\Geometry\TallBox;
use \tomkyle\yaphr\Geometry\WideBox;

# Coordinates
use \tomkyle\yaphr\Geometry\CropStartCoordinates;
use \tomkyle\yaphr\Geometry\NullCoordinates;

# Abstracts and Interfaces
use \tomkyle\yaphr\Geometry\CoordinatesInterface;
use \tomkyle\yaphr\Geometry\BoxAbstract;
use \tomkyle\yaphr\Geometry\BoxInterface;
use \tomkyle\yaphr\Geometry\CropBoxInterface;
```

\###Image filter classes

```
# Classes
use \tomkyle\yaphr\Filters\SharpenImage;
use \tomkyle\yaphr\Filters\UnsharpMask; # experimental
```

\###File system classes

```
# Classes
use \tomkyle\yaphr\FileSystem\CreateCacheDir;
use \tomkyle\yaphr\FileSystem\CheckReadableFile;
use \tomkyle\yaphr\FileSystem\DeliverImage;
use \tomkyle\yaphr\FileSystem\FileExtension;
use \tomkyle\yaphr\FileSystem\SaveImage;
use \tomkyle\yaphr\FileSystem\SaveGif;
use \tomkyle\yaphr\FileSystem\SaveJpeg;
use \tomkyle\yaphr\FileSystem\SavePng;

# Abstracts and Interfaces
use \tomkyle\yaphr\FileSystem\SaveImageAbstract;
use \tomkyle\yaphr\FileSystem\SaveImageInterface;
```

\###Exceptions

```
# Classes and Interfaces
use \tomkyle\yaphr\Exceptions\FileNotFound;
use \tomkyle\yaphr\Exceptions\YaphrException;
use \tomkyle\yaphr\Exceptions\YaphrExceptionInterface;
```

\###PHP resource aggregation

```
# Interfaces and traits
use \tomkyle\yaphr\Resources\ResourceAggregate;
use \tomkyle\yaphr\Resources\ResourceAggregateTrait;
```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 98.2% 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 ~18 days

Recently: every ~45 days

Total

11

Last Release

4050d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/412560?v=4)[Carsten Witt](/maintainers/tomkyle)[@tomkyle](https://github.com/tomkyle)

---

Top Contributors

[![tomkyle](https://avatars.githubusercontent.com/u/412560?v=4)](https://github.com/tomkyle "tomkyle (55 commits)")[![achrafsoltani](https://avatars.githubusercontent.com/u/1311229?v=4)](https://github.com/achrafsoltani "achrafsoltani (1 commits)")

---

Tags

phpimageresizegifpngjpgphotocropresizingcroppingsharpen

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tomkyle-yaphr/health.svg)

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

###  Alternatives

[stefangabos/zebra_image

A single-file, lightweight PHP library designed for efficient image manipulation featuring methods for modifying images and applying filters

141110.4k6](/packages/stefangabos-zebra-image)[kinglozzer/tinypng

TinyPNG PHP API

1292.1k2](/packages/kinglozzer-tinypng)[joseluisq/gimage

A PHP library for easy image handling.

1523.7k](/packages/joseluisq-gimage)[reliqarts/laravel-guided-image

Simplified and ready image manipulation for Laravel via intervention image.

351.4k](/packages/reliqarts-laravel-guided-image)

PHPackages © 2026

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