In a terminal, run ./base64enc.sh /path/to/file.png
Last active
December 14, 2015 21:29
-
-
Save jaikdean/5151877 to your computer and use it in GitHub Desktop.
Bash script to base64 encode the given file and output a CSS background-image declaration
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
#!/bin/bash | |
base64=`openssl base64 -in $1` | |
mime=`file -b --mime-type $1` | |
echo "background-image: url(data:${mime};base64,${base64});" | tr -d '\n' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment