ricardofiorani / php-legofy
Legofy的PHP端口
v1.0.1
2018-10-11 05:12 UTC
Requires
- php: ^7.1
- intervention/image: ^2.4
Requires (Dev)
- phpunit/phpunit: ^7.2
- spryker/code-sniffer: ^0.12.5
Suggests
- ext-gd: to use GD library based image processing.
- ext-imagick: to use Imagick based image processing.
This package is auto-updated.
Last update: 2024-08-29 05:00:21 UTC
README
这是什么?
PHP Legofy是一个PHP包,可以将静态图片转换为看起来像是用乐高块构建的效果。
它受到Python中制作的原始Legofy的启发https://github.com/JuanPotato/Legofy
需求
- PHP ^7.1 || ^8.0
- GD或ImageMagick
我只用GD测试过,但我相信intervention/image也能在ImageMagick上工作。
快速入门
通过composer
$ composer require ricardofiorani/php-legofy
通过源代码
$ git clone git@github.com:ricardofiorani/php-legofy.git
$ cd php-legofy
$ composer install
使用方法
<?php require 'vendor/autoload.php'; // The multiplier for the amount of legos on your image, or "legolution" :) $resolutionMultiplier = 1; // When set to true it will only use lego colors that exists in real world. $useLegoPalette = false; $legofy = new \RicardoFiorani\Legofy\Legofy(); // $source can be any acceptable parameter for intervention/image // Please see http://image.intervention.io/api/make $source = 'my/imagem/path/image.jpg'; /** *@var Intervention\Image\Image */ $output = $legofy->convertToLego($source, $resolutionMultiplier, $useLegoPalette); // Please see http://image.intervention.io/use/basics and http://image.intervention.io/use/http echo $output->response();
有关使用示例的更多示例,请参阅文档中的使用示例