Function to create data uri’s

These can be useful for embedding images into HTML/CSS/JS to save on HTTP requests.


function data_uri($file, $mime) {
  $contents=file_get_contents($file);
  $base64=base64_encode($contents);
  echo "data:$mime;base64,$base64";
}