Skip to content

Instantly share code, notes, and snippets.

@johnhunter
Created August 25, 2011 13:25
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/1170645 to your computer and use it in GitHub Desktop.
Save johnhunter/1170645 to your computer and use it in GitHub Desktop.
TextMate CSS 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'];
$contents = base64_encode(file_get_contents($path));
$out = <<<EOD
\${1:#selector} {
width: {$width}px;
height: {$height}px;
background: url('data:$mime;base64, $contents') \${3: \${4:no-repeat} \${5:scroll} \${6:top} \${7:left}};
EOD;
print $out;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment