Skip to content

Instantly share code, notes, and snippets.

@DC3
Created December 20, 2014 07:59
Show Gist options
  • Save DC3/a5f44863eb2cd5efa0ac to your computer and use it in GitHub Desktop.
Save DC3/a5f44863eb2cd5efa0ac to your computer and use it in GitHub Desktop.
base64.sh
function base64image() {
if [ -z "$1" ]
then
echo "give me a filename"
fi
filename=$(basename "$1")
extension="${filename##*.}"
out="$filename.base64"
str=$(base64 --wrap=0 "$1")
echo "data:image/$extension;base64,$str" | cat > "$out"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment