There are online tools like duri.me that allow to create a Data URI from an image file. Are there any tools that run locally on Linux to do the same?
Data URIs are usually just base64-encoded with the MIME-type stuck at the front. I use this homegrown script, which takes the filename as its first and only parameter and returns the data uri, already wrapped in
[0 1026 8:29:38] ~ % cat $(which cssify.sh) #!/bin/sh mimetype=$(file -bN --mime-type "$1") content=$(base64 -w0 < "$1") echo "url('data:$mimetype;base64,$content')"