Created
May 27, 2012 05:46
-
-
Save nicerobot/2802306 to your computer and use it in GitHub Desktop.
Convert references to image files into 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/sh | |
# Assumes pngs are in images/ under ./*.css | |
# Edits the files in-place. Make backups. | |
CSSD=${1:-${CSSD:-.}} | |
for c in $(ls ${CSSD}/*.css 2>/dev/null); do | |
for i in ${CSSD}/images/*.png; do | |
p=$(basename $i) | |
b="$(base64 ${i})" | |
perl -pi -e "s|images/${p}|data:image/png;base64,${b}|" ${c} | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment