Skip to content

Documentation for Imagick Layout Engine

Build Status Total Downloads Latest Stable Version License

A PHP library for creating complex image layouts with automatic positioning and sizing. This library provides a flexbox-like approach to image composition, making it easy to create structured layouts with text, images, and shapes.

  • PHP 8.3 or later
  • Linux (Windows not tested)
  • Imagick PHP extension

You can install the package via composer:

Terminal window
composer require kehet/imagick-layout-engine
// Create a new image
$width = 1500;
$height = 1000;
$imagick = new Imagick();
$imagick->newImage($width, $height, new ImagickPixel('white'));
// Create a row container with rectangles
$frame = new RowContainer();
$frame->addItem(new Rectangle(draw(fill: '#fee2e2')));
$frame->addItem(new Rectangle(draw(fill: '#fca5a5')));
$frame->addItem(new Rectangle(draw(fill: '#dc2626')));
$frame->addItem(new Rectangle(draw(fill: '#450a0a')));
// Draw container onto image
$frame->draw($imagick, 0, 0, $width, $height);
// Output image as PNG
$imagick->setImageFormat('png');
$imagick->writeImage('output.png');

For more examples, see documentation.

If you find any issues with the documentation, please open an issue on the GitHub repository.

Terminal window
composer test

When set, if snapshot file is missing, snapshot image will be automatically written to tests/__snapshots__/.

Terminal window
SAVE_SNAPSHOT=1 composer test -- --filter=YourTest

When set, a visual diff image will be saved to tests/temp/ whenever an image comparison is performed, regardless of pass/fail.

Terminal window
SAVE_IMAGE_DIFF=1 composer test -- --filter=YourTest

Please see CHANGELOG for more information on what has changed recently.

GNU GENERAL PUBLIC LICENSE version 3 or later. Please see License File for more information.