Skip to content

Instantly share code, notes, and snippets.

@woxtu
Created October 18, 2013 18:19
Show Gist options
  • Save woxtu/7045816 to your computer and use it in GitHub Desktop.
Save woxtu/7045816 to your computer and use it in GitHub Desktop.
Convert image to Data URI in Rouge.
;; Rouge 0.0.14
(require "base64")
(require "mime/types")
(let [filename (nth ARGV 0)]
(let [data-type (-> filename MIME.Types/of first)
data-str (-> filename Kernel/open .read Base64/encode64)]
(.write (Kernel/open (str (File/basename filename) ".html") "wb")
(str "<!DOCTYPE html>\n" "<img src=\"data:" data-type ";base64," data-str "\" />"))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment