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

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

salopot/image-generator
=======================

Image provider for Faker: solid color, gradient, gallery, LoremPixel, PicsumPhotos, Unsplash, LoremFlickr, PlaceKitten, PlaceImg

1.1.0(5y ago)521.0k1MITPHPPHP &gt;=7.1CI failing

Since Feb 18Pushed 5y ago1 watchersCompare

[ Source](https://github.com/salopot/image-generator)[ Packagist](https://packagist.org/packages/salopot/image-generator)[ RSS](/packages/salopot-image-generator/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (3)Versions (4)Used By (0)

Image generator
===============

[](#image-generator)

Image provider for [fzaninotto/Faker](https://github.com/fzaninotto/Faker) package with support multiple image sources and basic image manipulations

Local (fast &amp; no need internet connection):

- **SolidColor** - generate image filled single color
- **Gallery** - use local directory with images as source
- **Gradient** - generate gradient image

Remote:

- **LoremPixel** - [lorempixel.com](https://lorempixel.com) used in the original faker (very unstable now)
- **PicsumPhotos** - [picsum.photos](https://picsum.photos)
- **Unsplash** - [unsplash.com](https://source.unsplash.com)
- **LoremFlickr** - [loremflickr.com](https://loremflickr.com)
- **PlaceKitten** - [placekitten.com](http://placekitten.com)
- **PlaceImg** - [placeimg.com](https://placeimg.com) Warning: selector param use image resizing

Description
-----------

[](#description)

- Support multiple local &amp; remote sources (also you can write own)
- Support basic image manipulations
- Support several result formats (data-url, file, content)
- Support multiple extensions

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

[](#requirements)

- PHP &gt;=7.1
- GD Library (&gt;=2.0)
- Imagick PHP extension (&gt;=6.5.7)

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

[](#installation)

```
composer require --dev salopot/image-generator

```

Configuration
-------------

[](#configuration)

```
$generator = \Faker\Factory::create();
$imageProvider = new \Salopot\ImageGenerator\ImageProvider($generator);
// Configure some or all image sources
$imageProvider->addImageSource(new \Salopot\ImageGenerator\ImageSources\Local\SolidColorSource($imageProvider));
$imageProvider->addImageSource(new \Salopot\ImageGenerator\ImageSources\Local\GallerySource($imageProvider, '/dir/with/images'));
$imageProvider->addImageSource(new \Salopot\ImageGenerator\ImageSources\Local\SolidColorSource($imageProvider));
$imageProvider->addImageSource(new \Salopot\ImageGenerator\ImageSources\Remote\LoremPixelSource($imageProvider));
$imageProvider->addImageSource(new \Salopot\ImageGenerator\ImageSources\Remote\PicsumPhotosSource($imageProvider));
$imageProvider->addImageSource(new \Salopot\ImageGenerator\ImageSources\Remote\UnsplashSource($imageProvider));
$imageProvider->addImageSource(new \Salopot\ImageGenerator\ImageSources\Remote\PlaceKittenSource($imageProvider));
$imageProvider->addImageSource(new \Salopot\ImageGenerator\ImageSources\Remote\PlaceImgSource($imageProvider));
$generator->addProvider($imageProvider);
```

Usage
-----

[](#usage)

Basic example

```
$url = $generator->imageGenerator(640, 480)->getDataUrl();
```

Group random images for get the same with different changes

```
$item1MainImage = $generator->imageGenerator(640, 480, 'item-1')->getDataUrl();
$item1ThumbnailImage = $generator->imageGenerator(50, 50, 'item-1')->getDataUrl();

$item2MainImage = $generator->imageGenerator(640, 480, 'item-2')->getDataUrl();
$item2ThumbnailImage = $generator->imageGenerator(50, 50, 'item-2')->getDataUrl();
```

Choose one of the available sources.

```
$oneSourceUrl = $generator->imageGenerator(640, 480, null, 'SolidColor')
    ->grayscale()->getDataUrl();
$anotherSourceUrl = $generator->imageGenerator(640, 480, null, 'Unsplash')
    ->negative()->getDataUrl();
```

Support same image manipulations from any source:

```
$filePath = $generator->imageGenerator(640, 480)
    ->setExtension('png')
    ->grayscale()
    ->opacity(95)
    ->contrast(30)
    ->gamma(1.6)
    ->brightness(15)
    ->blur(80)
    ->negative()
    ->insertImage('/path/to/logo.png','left', 'bottom')
    ->text('Hello world', 35, 'left', 'top', 30, -90)
    ->insertImage('/path/to/logo.png', 'right', 'top')
->getFilePath('/path/to/dir');
```

Support several output formats:

```
$dataUrl = $generator->imageGenerator(640, 480)->getDataUrl();
$filePath = $generator->imageGenerator(640, 480)->getFilePath('/path/to/dir');
$content = $generator->imageGenerator(640, 480)->getContent();
```

\###Laravel The easiest to register faker with new configuration in Laravel: add next lines to the method app/Providers/AppServiceProvider.php::register

```
use Faker\Factory as FakerFactory;
use Faker\Generator as FakerGenerator;
use Salopot\ImageGenerator\ImageSources\Local;
use Salopot\ImageGenerator\ImageSources\Remote;

***

$this->app->singleton(FakerGenerator::class, function ($app) {
    $generator =  FakerFactory::create($app['config']->get('app.faker_locale', 'en_US'));

    // Additional faker providers
    $imageProvider = new \Salopot\ImageGenerator\ImageProvider($generator);
    $imageProvider->addImageSource(new Local\SolidColorSource($imageProvider));
    $imageProvider->addImageSource(new Local\GallerySource($imageProvider, '/dir/with/images'));
    $imageProvider->addImageSource(new Local\SolidColorSource($imageProvider));
    $imageProvider->addImageSource(new Remote\LoremPixelSource($imageProvider));
    $imageProvider->addImageSource(new Remote\PicsumPhotosSource($imageProvider));
    $imageProvider->addImageSource(new Remote\UnsplashSource($imageProvider));
    $imageProvider->addImageSource(new Remote\PlaceKittenSource($imageProvider));
    $imageProvider->addImageSource(new Remote\PlaceImgSource($imageProvider));
    $generator->addProvider($imageProvider);

   return $generator;
});
```

After that you can use faker (with ImageGenerator) in all standard laravel ways via DI: [factories](https://laravel.com/docs/master/database-testing#writing-factories), [resolve(\\Faker\\Generator::class)](https://laravel.com/docs/8.x/container#resolving), [constructor injection](https://laravel.com/docs/8.x/container#automatic-injection)

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 66.7% 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 ~186 days

Total

3

Last Release

1957d ago

PHP version history (2 changes)1.0.0PHP ^7.1

1.0.1PHP &gt;=7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/de866b61b006a3510267758ed2fcc6396fdad0eca7d09750d6aed2d9807f70f0?d=identicon)[salopot](/maintainers/salopot)

---

Top Contributors

[![salopot](https://avatars.githubusercontent.com/u/6479366?v=4)](https://github.com/salopot "salopot (4 commits)")[![f4bio](https://avatars.githubusercontent.com/u/4854092?v=4)](https://github.com/f4bio "f4bio (2 commits)")

---

Tags

laravelimagefakerlocalgradientUnsplashpicsum.photosplacekittenlorempixelLoremFlickrPlaceImg

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[intervention/image-laravel

Laravel Integration of Intervention Image

1588.9M183](/packages/intervention-image-laravel)[bkwld/croppa

Image thumbnail creation through specially formatted URLs for Laravel

506516.3k29](/packages/bkwld-croppa)[danihidayatx/image-optimizer

Optimize your Filament images before they reach your database. Forked from joshembling/image-optimizer for Filament v4 &amp; v5 support.

3218.1k](/packages/danihidayatx-image-optimizer)[intervention/image-driver-vips

libvips driver for Intervention Image

48177.4k11](/packages/intervention-image-driver-vips)[joshembling/image-optimizer

Optimize your Filament images before they reach your database.

113163.0k12](/packages/joshembling-image-optimizer)[alirezasedghi/laravel-image-faker

A library to generate fake images for Laravel

1631.6k6](/packages/alirezasedghi-laravel-image-faker)

PHPackages © 2026

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