Is it possible, like through src in <img src="/test.php" alt=""> to get the answer in base64 and display the image
2 answers
If you just want to give a picture from a .php file, you need to remember
header('Content-Type: image/jpeg'); If you plan to give the base64 browser, it will turn out badly - the browser somehow doesn’t really understand base64 as a file, and the file itself will swell to a third when encoded into this view.
But if you want to insert a small picture, then you generally need to insert a link to the picture at the stage of page generation, but the picture itself (just do not forget to specify gif / jpg / png mime type correctly), such code :
<img src="data:image/gif;base64,___а_тут_собственно_кодированное в b64__" /> If you want to work with a picture using a browser and suddenly you want base64, the answer has already flown
You can try this:
$binary = base64_decode($base64_image); $image= imagecreatefromstring($binary); header('Content-Type: image/jpeg'); imagejpeg($image); imagedestroy($image);
<img src="/test.png" alt="">, in htaccess translatetest.pngtotest.phpand process base64 in php - Saidolimполучить ответ в base64 и вывести изображение- Saidolim