Created
January 15, 2015 12:25
-
-
Save lesleh/4fa071d07750df0997a8 to your computer and use it in GitHub Desktop.
Bash script to create data URIs.
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 | |
| if [ "$#" -ne 1 ]; then | |
| echo "No filename specified." >&2 | |
| exit 1 | |
| fi | |
| FILENAME=$1 | |
| MIMETYPE=$(file -b --mime-type "$FILENAME") | |
| DATA=$(cat "$FILENAME" | base64) | |
| echo "data:${MIMETYPE};base64,${DATA}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment