Skip to content

Instantly share code, notes, and snippets.

@neolao
Created March 21, 2011 17:57
Show Gist options
  • Save neolao/879878 to your computer and use it in GitHub Desktop.
Save neolao/879878 to your computer and use it in GitHub Desktop.
<?php
// Get parameters
$arguments = $_SERVER['argv'];
array_shift($arguments);
if (empty($arguments)) {
die("File path is undefined\n");
}
$filePath = array_shift($arguments);
if (!is_file($filePath)) {
die("File not found : $filePath\n");
}
$image = file_get_contents($filePath);
$base64 = base64_encode($image);
echo 'data:image/png;base64,'.$base64."\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment