Identicon.getImageData() Method

Renders the icon and returns the icon data as a binary string.

public function getImageData(
    string $imageFormat = 'png'
    ) : string

Parameters

$imageFormat specifies the format of the generated icon. Supported formats are png and svg.

Examples

The following code shows how to use getImageData to return an identicon to the client. This code can be simplified by using displayImage() instead.

<?php
include_once('vendor/autoload.php');

$icon = new \Jdenticon\Identicon(array(
    'value' => 'Test icon',
    'size' => 100
));

header('Content-Type: image/png');
echo $icon->getImageData('png');

Remarks

Remember to set an appropriate Content-Type header when writing the image data to the output. Alternatively use displayImage() which does this for you.