Skip to content

Instantly share code, notes, and snippets.

@khoand0000
Created September 11, 2014 15:12
Show Gist options
  • Save khoand0000/5b486759f14bdf83a53e to your computer and use it in GitHub Desktop.
Save khoand0000/5b486759f14bdf83a53e to your computer and use it in GitHub Desktop.
function encodeimg($file) {
$contents = file_get_contents($file);
$base64 = base64_encode($contents);
$imagetype = exif_imagetype($file);
$mime = image_type_to_mime_type($imagetype);
return "data:$mime;base64,$base64";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment