Created
December 20, 2014 07:59
-
-
Save DC3/a5f44863eb2cd5efa0ac to your computer and use it in GitHub Desktop.
base64.sh
This file contains hidden or 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
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