Last active
December 17, 2015 00:49
-
-
Save willread/5523843 to your computer and use it in GitHub Desktop.
Outputs a css file containing a class declaration for each image file in the current folder, with the binary contents of those images base64 encoded as data urls as well as their width and height. Dots in filenames are replaced with underscores. Using the images is as simple as <img class="filename_extension">, where an image called "filename.ex…
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
for f in `ls | egrep "\.jpg|\.jpeg|\.gif|\.png$"`; do echo -e ".`echo $f | tr . "_"` {\n\twidth: `identify -format '%w' $f`px;\n\theight: `identify -format '%h' $f`px;\n\tbackground: url(data:image/${f#*.};base64,"; openssl base64 -in $f | tr -d "\n" | tr -d "\r"; echo -e ");\n}\n"; done > images.css |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment