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

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

nicoverbruggen/image-generator
==============================

Generate placeholder images with a specific size, color and text (optional).

v4.1.0(2mo ago)3032.1k—5.4%6MITPHPPHP &gt;=8.1CI passing

Since Dec 6Pushed 2mo agoCompare

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

READMEChangelog (6)Dependencies (2)Versions (11)Used By (0)

Image Generator
===============

[](#image-generator)

This package is intended to be used for quickly generating placeholder images with a specific size, color and text. For more complex use cases, you may want to turn to something like [stil/gd-text](https://github.com/stil/gd-text).

Requirements
------------

[](#requirements)

- PHP 8.1 or higher
- GD extension

Usage
-----

[](#usage)

Make sure you require this package in your composer.json:

```
composer require nicoverbruggen/image-generator

```

See [the example source file](examples/saved.php) that is used to generate and save the sample images. You can generate the following examples:

[![The barebones example](doc/examples/barebones.png)](doc/examples/barebones.png)[![A multiline example](doc/examples/multiline.png)](doc/examples/multiline.png)[![An avatar](doc/examples/avatar.png)](doc/examples/avatar.png)

Please note that for testing purposes, I used Roboto Black as the TrueType font. (This font is not included in this repository.)

Here's a few examples of what you can do with this package:

### Save images to a path

[](#save-images-to-a-path)

```
use NicoVerbruggen\ImageGenerator\ImageGenerator;

(new ImageGenerator())->generate(output: __DIR__ . "/image_example.png", size: '200x200');
```

### Generate `base64` encoded images inline

[](#generate-base64-encoded-images-inline)

In addition to saving placeholder images to a particular location, you can also output a base64 encoded string:

```
use NicoVerbruggen\ImageGenerator\ImageGenerator;

$output = (new ImageGenerator())->generate(output: 'base64', size: '200x200');

echo "";
```

A useful use case may be achieved after declare your own helper, like so:

```
function placeholder_image(string $size = '500x500'): string {
    return (new ImageGenerator())->generate(output: 'base64', size: $size);
}
```

This use case can be useful when used in combination with frameworks like Laravel or Symfony:

```

    Item

```

### Directly output images

[](#directly-output-images)

You can also check out [the other source file](examples/direct.php). You can point your browser directly at this file (assuming you're running a PHP server, of course) and it will directly return a file since the path is set to `null`.

### Server mode

[](#server-mode)

You can also point your PHP installation's webroot to the `server` directory, and generate images via URL.

- The `size` parameter is used to size the placeholder images.
- The `background_color` parameter is used to set the background color.
- The `text_color` parameter is used to set the color of the text (of the dimensions).

Please note that you should not use `#` in the URL for the hexadecimal notation for colors!

You can then link to the domain you're using to host these placeholders.

For example, if it is `image-generator.test`:

```

    Item

```

Notes
-----

[](#notes)

If you do not supply a TrueType font path:

- you will be limited in font size options (1 through 5)
- you will not be able to render multiline text

Upgrade guide
-------------

[](#upgrade-guide)

### v2 to v3:

[](#v2-to-v3)

In `ImageGenerator`, `makePlaceholderImage()` has been removed. You need to replace all usages of it with `generate()`.

### v3 to v4:

[](#v3-to-v4)

In `ImageGenerator`, `generate()`'s `path` parameter has been replaced with `output`. If you use named parameters, you will need to update your usage of this method.

It works the same way, but you have more options for this parameter now, in particular `base64` is now a valid value for that parameter.

Tests
-----

[](#tests)

```
./vendor/bin/phpunit tests

```

Contributions
-------------

[](#contributions)

I am not planning to expand the features of this package at this time. If you've made an improvement or fixed something, you are free to send me a pull request.

License
-------

[](#license)

MIT.

See also: [LICENSE](LICENSE).

###  Health Score

59

—

FairBetter than 99% of packages

Maintenance86

Actively maintained with recent releases

Popularity40

Moderate usage in the ecosystem

Community11

Small or concentrated contributor base

Maturity78

Established project with proven stability

 Bus Factor1

Top contributor holds 97.3% 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 ~377 days

Recently: every ~394 days

Total

9

Last Release

66d ago

Major Versions

v0.1.0 → v1.0.02017-12-06

v1.0.0 → v2.0.02021-03-14

v2.2.0 → v3.0.02024-08-07

v3.0.0 → v4.0.02025-12-15

PHP version history (3 changes)v0.1.0PHP &gt;=7.0

v2.0.0PHP &gt;=8.0

v3.0.0PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/9b101844b491650ca48000b4c1490126bb44ce0a684ed37aad10b3096c2f6bd9?d=identicon)[nicoverbruggen](/maintainers/nicoverbruggen)

---

Top Contributors

[![nicoverbruggen](https://avatars.githubusercontent.com/u/3715845?v=4)](https://github.com/nicoverbruggen "nicoverbruggen (36 commits)")[![mjot](https://avatars.githubusercontent.com/u/1445991?v=4)](https://github.com/mjot "mjot (1 commits)")

---

Tags

fontmultilinephpplaceholder-image

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[milon/barcode

Barcode generator like Qr Code, PDF417, C39, C39+, C39E, C39E+, C93, S25, S25+, I25, I25+, C128, C128A, C128B, C128C, 2-Digits UPC-Based Extention, 5-Digits UPC-Based Extention, EAN 8, EAN 13, UPC-A, UPC-E, MSI (Variation of Plessey code)

1.5k13.3M39](/packages/milon-barcode)[bkwld/croppa

Image thumbnail creation through specially formatted URLs for Laravel

510496.0k23](/packages/bkwld-croppa)[goat1000/svggraph

Generates SVG graphs

132849.6k3](/packages/goat1000-svggraph)[cohensive/embed

Media Embed (for Laravel or as a standalone).

120370.4k](/packages/cohensive-embed)[netresearch/rte-ckeditor-image

Image support in CKEditor for the TYPO3 ecosystem - by Netresearch

63991.3k4](/packages/netresearch-rte-ckeditor-image)[humanmade/tachyon-plugin

Rewrites WordPress image URLs to use Tachyon

87338.5k2](/packages/humanmade-tachyon-plugin)

PHPackages © 2026

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