Created
April 21, 2020 14:24
-
-
Save skchronicles/49665181da4f94435be613dca1057b2f to your computer and use it in GitHub Desktop.
Bash one-liners: covert images to base64 and embed in HTML
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
# USAGE: image2html /path/to/images/*.png > out.html | |
function image2html(){ | |
for f in $@; do b=$(cat "$f" | base64 -w 0); echo "<img src=\"data:image/${f##*.};base64,${b}\" alt=\"${f%.*}\">"; done | |
} | |
export -f image2html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment