PHPackages                             arjanwestdorp/imaginary-client - 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. arjanwestdorp/imaginary-client

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

arjanwestdorp/imaginary-client
==============================

A client for the imaginary image service

1.0.6(8y ago)115.8k1MITPHPPHP &gt;=5.6.0

Since May 10Pushed 8y ago2 watchersCompare

[ Source](https://github.com/arjanwestdorp/imaginary-client)[ Packagist](https://packagist.org/packages/arjanwestdorp/imaginary-client)[ RSS](/packages/arjanwestdorp-imaginary-client/feed)WikiDiscussions master Synced today

READMEChangelog (7)Dependencies (1)Versions (9)Used By (1)

Imaginary client
================

[](#imaginary-client)

[![Latest Stable Version](https://camo.githubusercontent.com/bbe1e57559f5e48985f433429e15e9ef6dd6db2b349017da9c20b9c007a81f0a/68747470733a2f2f706f7365722e707567782e6f72672f61726a616e77657374646f72702f696d6167696e6172792d636c69656e742f762f737461626c653f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/arjanwestdorp/imaginary-client)[![License](https://camo.githubusercontent.com/aefa33164b3ec9871ce91707626e304df2425891d4b7b0793fd9ea41666b541d/68747470733a2f2f706f7365722e707567782e6f72672f61726a616e77657374646f72702f696d6167696e6172792d636c69656e742f6c6963656e73653f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/arjanwestdorp/imaginary-client)[![Build Status](https://camo.githubusercontent.com/9b15bfaaf051d1254e583ad5cd1cd3ca795b7bd0abb68f48b9ca01edc6fac70e/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f61726a616e77657374646f72702f696d6167696e6172792d636c69656e742f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/arjanwestdorp/imaginary-client)[![Quality Score](https://camo.githubusercontent.com/b5790d67821742dcc45871fe0f97a77bf447e15e6b85c21c3910aa952c7af2f7/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f61726a616e77657374646f72702f696d6167696e6172792d636c69656e742e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/arjanwestdorp/imaginary-client)[![Coverage](https://camo.githubusercontent.com/88157e3a4a73614d9ceb3603ee7c0dc42c458a8a8c66b58f4ce559e3463fcb5b/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f61726a616e77657374646f72702f696d6167696e6172792d636c69656e742e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/arjanwestdorp/imaginary-client)

Client for the imaginary image service. Imaginary is a service build to resize images on the fly. Unfortunately that service is not open sourced yet.

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

[](#installation)

The recommended way to install the client is through composer:

```
composer require arjanwestdorp/imaginary-client

```

Usage
-----

[](#usage)

```
$client = new Client([
    'client' => 'CLIENT',
    'url' => 'https://imaginaryurl.com',
]);

$client->fetch('http://www.test.com/test.jpg')->url();
// https://imaginaryurl.com/CLIENT/image/fetch/http://www.test.com/test.jpg

$client->fetch('http://www.test.com/test.jpg')
    ->width(100)
    ->height(100)
    ->url();

// https://imaginaryurl.com/CLIENT/image/fetch/w_100,h_100/http://www.test.com/test.jpg
```

### Predefined definitions

[](#predefined-definitions)

You can add predefined sets of manipulations. The idea is that you can reuse the same manipulation multiple times in your whole application by defining it only once.

```
$client->define('landscape', function($imaginary){
    $imaginary->width(400)
        ->height(300)
        ->fit();
});

$client->fetch('http://www.test.com/test.jpg')
    ->landscape()
    ->url();
// https://imaginaryurl.com/CLIENT/image/fetch/w_400,h_300,c_fit/http://www.test.com/test.jpg

```

Options
-------

[](#options)

#### width($width)

[](#widthwidth)

Manipulate the width of the image in pixels.

#### height($height)

[](#heightheight)

Manipulate the height of the image in pixels.

#### fit($gravity = null)

[](#fitgravity--null)

Fit the resizing in the given dimensions (width, height). By setting the gravity you can mark the position which the cutout will be taken from. By default it will cutout from the center. Options are:

- top-left
- top
- top-right
- left
- right
- center (default)
- bottom-left
- bottom
- bottom-right

#### circle($radius = 'max')

[](#circleradius--max)

Make a circle image. Setting no radius, it will use the size of the image and make it a circle. By setting a radius the image will be resized to match that radius. If the image is bigger then the radius it will automatically use the `fit('center')` manipulation before making a circle. The circle manipulation will be called after the resizing manipulations like width and height, so you can resize the image to your needs before applying the circle.

Security
--------

[](#security)

If you discover any security issues, please email  instead of creating an issue.

Credits
-------

[](#credits)

- [Arjan Westdorp](https://github.com/arjanwestdorp)
- [Trait Development](http://www.trait-development.nl)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity63

Established project with proven stability

 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

Every ~62 days

Recently: every ~93 days

Total

7

Last Release

2969d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6b8e9f6f76f71bca41a5f56025678c55340a73575ec67924873bed1f37d0aa3f?d=identicon)[arjanwestdorp](/maintainers/arjanwestdorp)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/arjanwestdorp-imaginary-client/health.svg)

```
[![Health](https://phpackages.com/badges/arjanwestdorp-imaginary-client/health.svg)](https://phpackages.com/packages/arjanwestdorp-imaginary-client)
```

###  Alternatives

[goat1000/svggraph

Generates SVG graphs

135911.1k3](/packages/goat1000-svggraph)[gravatarphp/gravatar

Gravatar URL builder which is most commonly called as a Gravatar library

16653.6k2](/packages/gravatarphp-gravatar)[rsoury/wp-imgix

Rewrites WordPress image URLs to use ImgIX

167.2k](/packages/rsoury-wp-imgix)

PHPackages © 2026

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