Created
August 25, 2011 13:25
-
-
Save johnhunter/1170645 to your computer and use it in GitHub Desktop.
TextMate CSS command: drop base64 encoded
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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