Identicon.getImageData() Method

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

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


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


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


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

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


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