php gd image create from string


 

php gd image create from string

This example shows how to display image from string in php gd Library.

This example shows how to display image from string in php gd Library.

<?php

$String = 'iVBORw0KGgoAAAANSUhEUgAAABwAAAASCAMAAAB/2U7WAAAABl'

. 'BMVEUAAAD///+l2Z/dAAAASUlEQVR4XqWQUQoAIAxC2/0vXZDr'

. 'EX4IJTRkb7lobNUStXsB0jIXIAMSsQnWlsV+wULF4Avk9fLq2r'

. '8a5HSE35Q3eO2XP1A1wQkZSgETvDtKdQAAAABJRU5ErkJggg==';

$String = base64_decode($String);

$image = imagecreatefromstring($String);

if ($image !== false) {

header('Content-Type: image/png');

imagepng($image);

}

else {

echo 'An error occured.';

}

?>

After running the program you will get the following output

Ads