Skip to content

Instantly share code, notes, and snippets.

@8bitDesigner
Last active October 3, 2015 17:28
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 8bitDesigner/2494544 to your computer and use it in GitHub Desktop.
Save 8bitDesigner/2494544 to your computer and use it in GitHub Desktop.
Data URI utility
#! /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