1. Go to this page and download the library: Download usarise/identicon 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/ */
usarise / identicon example snippets
declare(strict_types=1);
;
use Usarise\Identicon\Image\Svg\Canvas as SvgCanvas;
$identicon = new Identicon(
new SvgCanvas(),
420,
);
$response = $identicon->generate('test');
header("Content-type: {$response->mimeType}");
echo (string) $response;
declare(strict_types=1);
;
use Usarise\Identicon\Image\Svg\Canvas as SvgCanvas;
$identicon = new Identicon(
new SvgCanvas(),
420,
);
$response = $identicon->generate('test');
$response->save("test.{$response->format}");
declare(strict_types=1);
;
use Usarise\Identicon\Image\Svg\Canvas as SvgCanvas;
$identicon = new Identicon(
new SvgCanvas(),
420,
);
$response = $identicon->generate('test');
$data = sprintf(
'data:%s;base64,%s',
$response->mimeType,
base64_encode(
(string) $response,
),
);
use Usarise\Identicon\Image\Svg\Canvas as SvgCanvas;
use Usarise\Identicon\{Identicon, Resolution};
$identicon = new Identicon(
image: new SvgCanvas(), // implementation Usarise\Identicon\Image\CanvasInterface
size: 420, // 420x420 pixels
resolution: Resolution::Medium, // Resolution 10x10 (Default)
);
use Usarise\Identicon\Image\Gd\Canvas as GdCanvas;
use Usarise\Identicon\Image\Imagick\Canvas as ImagickCanvas;
use Usarise\Identicon\Image\Svg\Canvas as SvgCanvas;