niklasbr / quick-magick
Image placeholder provider for Faker
Requires
- php: ^8.3
- ext-imagick: *
- fakerphp/faker: ^1.24.1
- spatie/color: ^1.8 || ^2.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.75.0
- pestphp/pest: ^3.8.2 || ^4.0.0
- phpstan/phpstan: ^2.1.17
README
A very fast Faker-compatible image placeholder library for PHP. Generate gradients, plasma effects, repeating patterns, solid color canvases, labels, captions, and random image variants without any network requests.
Installation
Install this Faker provider with Composer:
composer require niklasbr/quick-magick
Quick start
Register the QuickMagick Faker provider and generate an image with category-specific arguments.
use Faker\Factory; use NiklasBr\QuickMagick\QuickMagick; $faker = Factory::create(); $faker->addProvider(new QuickMagick($faker));
// Simple image with only default parameters $imageData = $faker->image();
// A linear gradient (using mixed colour notation) $imageData = $faker->image(category: 'LINEAR_GRADIENT', word: '#1100ff-magenta');
Faker provider features
QuickMagick adds a Faker-compatible image provider that uses the same API shape as the built-in Faker image provider, with additional image generation options:
- Generate image files directly with
image() - Return raw image blob bytes with
imageData() - Build data URL:s with
imageUrl() - Create and store image files with
createImageFile() - Generate random images of a certain style/category with
randomSolidColor(),randomGradient(),randomPattern(),randomPlasma()andrandomImage() - Supports formats
png,jpeg,gif,webp,tiff,bmp
Example categories
The library supports several visual categories and type-specific arguments:
SOLID_COLOR— flat color canvas, chosen with a hex color string like#2E86ABLINEAR_GRADIENT— linear gradient, specified with a color pair like#667EEA-#764BA2RADIAL_GRADIENT— radial gradient, also using paired colorsPATTERN— repeating texture pattern, selected with a pattern tokenPLASMA— plasma noise effect, optionally with a seed colorLABEL— single-line text label imageCAPTION— multi-line wrapped text image
Documentation and examples
Example images and their generation arguments are available in docs/documentation.md.
License
This package is available under two licenses:
- Affero GPL Version 3, 19 November 2007, this is the default license.
- BSD-3-Clause via commercial agreement, available via donation to charity. Grants a limited warranty and fitness-for-purpose promise.

