Skip to content

Instantly share code, notes, and snippets.

@johnhunter
Created August 25, 2011 13:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnhunter/1170635 to your computer and use it in GitHub Desktop.
Save johnhunter/1170635 to your computer and use it in GitHub Desktop.
TextMate command: drop base64 encoded
#!/usr/bin/env php
<?php
# John Hunter <https://github.com/johnhunter>
$path = getenv('TM_DROPPED_FILE');
$path_parts = pathinfo($path);
$info = getimagesize($path);
list($width, $height, $type, $attr) = $info;
$mime = $info['mime'];
print $alt;
$contents = base64_encode(file_get_contents($path));
$out = <<<EOD
<img alt="" $attr src="data:$mime;base64, $contents">
EOD;
print $out;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment