Base64 Encoding for Images in PHP
Base64 is an encoding format that
represent binary data. Google new feature instant previews are in text format, here Google requesting images(screen shots) are in string format to reduce server load time.
In this post I will show you how to make images to strings with PHP.
PHP images to strings
PHP terminology there is a function called base64_encode().
<?php
$img_src = "image/sample.png";
$imgbinary = fread(fopen($img_src, "r"),
filesize($img_src));
$img_str = base64_encode($imgbinary);
echo '<img src="data:image/jpg;base64,'.
$img_str.'" />';
?>