ricardofiorani / php-legofy
A PHP Port of Legofy
Installs: 616
Dependents: 0
Suggesters: 0
Security: 0
Stars: 167
Watchers: 8
Forks: 11
Open Issues: 1
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-11-29 05:39:06 UTC
README
What is this ?
PHP Legofy is a PHP package that takes a static image and makes it so that it looks as if it was built out of LEGO.
It was inspired by the original Legofy made in Python https://github.com/JuanPotato/Legofy
Basically it transforms this: Into this:
Requirements
- PHP ^7.1 || ^8.0
- GD or ImageMagick
I tested it with GD only but I'm trusting intervention/image that this will work on ImageMagick as well.
Quickstart
Via composer:
$ composer require ricardofiorani/php-legofy
Via source:
$ git clone git@github.com:ricardofiorani/php-legofy.git
$ cd php-legofy
$ composer install
Usage:
<?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();
For more examples of usage please see the usage examples on documentation