Skip to content

NiklasBr/quick-magick

Repository files navigation

QuickMagick

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.

Coverage PHPStan Dependabot

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();

default_output.png

// A linear gradient (using mixed colour notation)
$imageData = $faker->image(category: 'LINEAR_GRADIENT', word: '#1100ff-magenta');

linear_gradient.png

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() and randomImage()
  • 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 #2E86AB
  • LINEAR_GRADIENT — linear gradient, specified with a color pair like #667EEA-#764BA2
  • RADIAL_GRADIENT — radial gradient, also using paired colors
  • PATTERN — repeating texture pattern, selected with a pattern token
  • PLASMA — plasma noise effect, optionally with a seed color
  • LABEL — single-line text label image
  • CAPTION — 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:

About

A high-performance placeholder image generator with full test coverage and no network requests to third-party services.

Resources

License

Stars

Watchers

Forks

Contributors

Languages