bjorvack / image-stacker
Image stacker 是一个将不同图像合并为单个图像的包。
0.3
2016-09-29 15:13 UTC
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-09-10 19:21:33 UTC
README
Image stacker 是一个将不同图像合并为单个图像的包。
安装
composer install bjorvack/image-stacker
使用方法
创建新的堆叠
创建新的堆叠只需要堆叠名称。给堆叠添加额外的参数,如最大宽度或高度限制,可以限制堆叠的生长方式。
$stacker = new Stacker('name'); $stacker = new Stacker('name', <int maxWidth>, <int maxWidth>, <bool growVertical>, <bool growHorizontal>);
向堆叠添加图像
使用 addImage
函数可以将一个 Image
对象添加到堆叠中。
图像需要一个路径和名称属性。如果未提供宽度/高度,则从文件本身加载文件的大小。
$image = new Image('path', 'name', <int width>, <int height>); $stacker->addImage($image);
创建堆叠图像
$image = Image::createFromStacker($stacker, 'storagepath');
获取堆叠中图像的位置
当调用堆叠函数时,图像的 x
和 y
属性被设置。您可以使用 getX
和 getY
函数访问它们。
foreach($stacker->getImages() as $image) { $image->getY(); $image->getX(); }
导出器
堆叠可以导出为 .json
文件或 .css
文件。将自动生成 .png
文件。
$stacker = new Stacker('name'); JsonExporter::save($stacker, 'path'); StylesheetExporter::save($stacker, 'path');