Last active
October 3, 2015 17:28
-
-
Save 8bitDesigner/2494544 to your computer and use it in GitHub Desktop.
Data URI utility
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
#! /bin/bash | |
function usage { | |
echo "Usage: $0 /path/to/file" | |
[[ -n $1 ]] && echo $1 | |
exit 1 | |
} | |
# Only run if we have a single image file | |
[[ $# != 1 ]] && usage | |
[[ ! -e $1 ]] && usage "$1 does not exist" | |
# Grab a binary dump of the file | |
type=`file -I $file | awk '{print $2}'` | |
bin=`base64 $file` | |
echo "data:${type}base64, $bin" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment