PHP code example of isaeken / blockies

1. Go to this page and download the library: Download isaeken/blockies library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

isaeken / blockies example snippets


$blockies = new \IsaEken\Blockies\Blockies;
$blockies->draw();

echo $blockies->svg(); // <svg...
$blockies->image()->save('image.jpg'); // save generated image
echo $blockies->image()->encode('data-url')->encoded; // data:image/png;base64...

$blockies = new \IsaEken\Blockies\Blockies([
    'seed' => '130ef2f0a8b713',
    'size' => 64,
    'background' => \Spatie\Color\Hex::fromString('#ff0000')->toHsl(),
]);

// or

$blockies = new \IsaEken\Blockies\Blockies;

$blockies->draw();

file_put_contents('image.svg', $blockies->svg());

$blockies->image()->greyscale()->save('black_and_white.jpg');

$blockies->refresh();
$blockies->image(); // this is a new image.

$blockies
    ->setSize(120)
    ->setBackground(\Spatie\Color\Hex::fromString('#00ff00')->toHsl())
    ->draw()
    ->image();

$blockies->setSeed('130ef2f0a8b713')->draw()->image();

$blockies->getSeed(); // string
$blockies->getBackground(); // \Spatie\Color\Hsl
$blockies->getSize(); // int