Created
November 13, 2018 11:34
-
-
Save awesome/00fad96c6e7647d23ab231ccb8192751 to your computer and use it in GitHub Desktop.
image to datauri one-liner ruby @soawesomeman
This file contains 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
require 'open-uri' | |
require 'base64' | |
filename = "lib/templates/assets/image.jpg" | |
datauri = "data:image/#{File.extname(filename).delete('.')};base64," + Base64.strict_encode64(open(filename).read) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment