Here is my code:
$data = \'iVBORw0KGgoAAAANSUhEUgAAABwAAAASCAMAAAB/2U7WAAAABl\'
. \'BMVEUAAAD///+l2Z/dAAAASUlEQVR4XqWQUQoAIAxC2/0vXZDr\'
. \'EX4IJT
Below code will be helpful:
$data = 'code in bytes'; // replace with an image string in bytes
$data = base64_decode($data); // decode an image
$im = imagecreatefromstring($data); // php function to create image from string
// condition check if valid conversion
if ($im !== false)
{
// saves an image to specific location
$resp = imagepng($im, $_SERVER['DOCUMENT_ROOT'].'folder_location/'.date('ymdhis').'.png');
// frees image from memory
imagedestroy($im);
}
else
{
// show if any error in bytes data for image
echo 'An error occurred.';
}
Please suggest if some other better way of doing !