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

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

drroach/dynamic-image
=====================

Dynamic image loading script that generates images of the requested size on the fly.

v0.2.3(8y ago)1118[3 PRs](https://github.com/DrRoach/DynamicImage/pulls)PHP

Since Aug 7Pushed 4y ago4 watchersCompare

[ Source](https://github.com/DrRoach/DynamicImage)[ Packagist](https://packagist.org/packages/drroach/dynamic-image)[ RSS](/packages/drroach-dynamic-image/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (4)Dependencies (1)Versions (11)Used By (0)

DynamicImage
============

[](#dynamicimage)

[![Logo](./logo.png)](./logo.png)

Create dynamically sized images on the fly so that they don't need to be resized when added or uploaded.

The goal of this script is to allow images to be generated on the fly to any size. This is done by using PHPs imagick libraries to creating images in a fraction of a second.

This script has a fully functioning file based cache system which renews when original images are updated. Images are generated to scale and generated to high resolution. There is also support for images that are hosted on seperate endpoints.

`JPG`, `JPEG`, `PNG` and `GIF` images are supported.

- [Become a backer or sponsor on Patreon](https://www.patreon.com/DrRoach)

### Params

[](#params)

The parameters are expected as a `key`, `value` array and passed when the object is created.

`filename` - `required` This is the original image filename including it's extension, for example, `snorkel.jpg`. This image can be of any size any will be rendered in near perferct resolution.

`width` - `required` This is the desired width of the image.

`height` - `required` This is the desired height of the image.

`image_directory` - This is the directory that all of your original images are held in. This cannot move 'up' through your filesystem to keep the script as a whole, more secure. This MUST also end with a trailing slash.

`debug` - If you wish for errors to be turned on, then you can set this to `true` to display any errors that may be occuring.

`image_missing` - If the requested image isn't found then this image is returned instead. This means that you never get a blank response and there's always something that you can display.

`exceptions` - Parameter to set whether or not you wish for exceptions to be thrown by the script. The default value is `false` so if you want exceptions to be thrown then you must set this to `true` when creating the object.

`validate_image` - Flag to indicate whether or not you want to check for the requested images' existance before looking to see if the image exists in cache. This means that if the image gets updated after it's been saved to cache then the image wont be regenerated. By default this is set to `true`.

`invalidate_cache` - Parameter to set whether or not the cache image should be invalidated after x amount of seconds. This means you can re-generate cache images every day for example.

### Example AJAX request to load an image from a seperate domain

[](#example-ajax-request-to-load-an-image-from-a-seperate-domain)

Request URL

`http://yousite.com/loadimage.php?filename=snorkel.jpg&width=500&height=500`

loadimage.php

```

```

HTML

```

```

### Potential Issues

[](#potential-issues)

Make sure that your cache folder is writable and that the apache user has permission to write on your machine. Usually user `www-data`.

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity59

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

Every ~5 days

Total

4

Last Release

3233d ago

### Community

Maintainers

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

---

Top Contributors

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

###  Code Quality

TestsCodeception

### Embed Badge

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

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

###  Alternatives

[goat1000/svggraph

Generates SVG graphs

133890.0k3](/packages/goat1000-svggraph)[imagekit/imagekit

PHP library for Imagekit

46877.3k10](/packages/imagekit-imagekit)[gravatarphp/gravatar

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

16653.6k2](/packages/gravatarphp-gravatar)

PHPackages © 2026

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