Created
September 15, 2021 03:45
-
-
Save Fortyseven/9265fd3576682f1941971794b9d4b802 to your computer and use it in GitHub Desktop.
This file contains 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/sh | |
if [ -z "$1" ]; then | |
echo "usage: data-url file" >&2 | |
exit 1 | |
fi | |
mimetype=$(file -bN --mime-type "$1") | |
content=$(base64 < "$1") | |
echo "data:$mimetype;base64,$content" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://blog.jiayu.co/2019/02/create-data-urls-from-the-command-line/