Wednesday, September 11, 2013

Image ENCODING using Base64

Base64 Encoding for Images



Base64 is an encoding format that represent binary data.Now a days lot of website use binary encryption scheme to secure their image link from user. Google,Facebook etc using this method to encrypt their image link.


use following code:

<?php
 
  $img_src = "sample-image.png";    // add image link
  $imgbinary = fread(fopen($img_src, "r"), filesize($img_src));
  $img_str = base64_encode($imgbinary);               //image encoding
  echo '<img src="data:image/jpg;base64,'.$img_str.'" />';

 ?>

This is all about the Image ENCODING using Base64. This technique helps you to secure images in you websites.



No comments:

Post a Comment