bjorvack / image-stacker
Image stacker is a package to combine different images to one single image.
Requires
- php: >=5.5.0
- intervention/image: ^2.3
Requires (Dev)
- phpunit/phpunit: ^5.2 || ^4.8
This package is not auto-updated.
Last update: 2024-11-05 20:00:38 UTC
README
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');