Skip to content

Instantly share code, notes, and snippets.

@msikma
Created April 20, 2019 15:04
Show Gist options
  • Save msikma/67b5a48dd6a36e6a8c7e7a78e6fcf644 to your computer and use it in GitHub Desktop.
Save msikma/67b5a48dd6a36e6a8c7e7a78e6fcf644 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Retrieves the mime type, e.g. 'image/png'
mime=$(file -bN --mime-type "$1")
# Converts the file itself to Base64
content=$(base64 -b0 < "$1")
printf "url('data:%s;base64,%s')\n" $mime $content
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment