Identicon.displayImage() Method

Renders the icon directly to the page output.

public function displayImage(
    string $imageFormat = 'png'
    ) : void

Parameters

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

Examples

The following code shows how to use displayImage to return an identicon to the client.

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

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

Remarks

The method will set the Content-Type HTTP header. You are recommended to set an appropriate Cache-Control header before calling this method to ensure the icon is cached client side.

The method won't call exit() or die(). Be sure not to write any output to the client before or after this method is called, as it will most likely corrupt the icon.