bjorvack/image-stacker

Image stacker is a package to combine different images to one single image.

0.3 2016-09-29 15:13 UTC

This package is not auto-updated.

Last update: 2024-05-21 18:04:08 UTC


README

Latest Version GitHub issues open Packagist Build Status

Image stacker is a package to combine different images to one single image.

Instalation

composer install bjorvack/image-stacker

Usage

Creating a new stack

Creating a new stack only requires a stack name. Giving the stack additional parameters like max width or height limits the way the stack can grow.

$stacker = new Stacker('name');
$stacker = new Stacker('name', <int maxWidth>, <int maxWidth>, <bool growVertical>, <bool growHorizontal>);

Adding images to the stack

Using the the addImage function an Image object can be added to the stack.

An Image needs a path and a name attribute. If the width / height aren't provided the size of the file is loaded from the file itself.

$image = new Image('path', 'name', <int width>, <int height>);
$stacker->addImage($image);

Creating the stacked image

$image = Image::createFromStacker($stacker, 'storagepath');

Getting the position of an image in the stack

When the stack function is called the x and y attributes for the images are set. You can access the using the getX and getY functions.

foreach($stacker->getImages() as $image) {
    $image->getY();
    $image->getX();
}

Exporters

A stack can be exported as a .json file or a .css file. The .png file is made automatically.

$stacker = new Stacker('name');

JsonExporter::save($stacker, 'path');
StylesheetExporter::save($stacker, 'path');