Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
(defn render-image [image]
(let [out (ByteArrayOutputStream.)]
(do (ImageIO/write image "png" out) (ByteArrayInputStream. (.toByteArray out)))))
; ":use" needed for compojure.response
(extend-protocol Renderable
BufferedImage
(render [image _]
(-> (ring.util.response/response (render-image image))
(ring.util.response/content-type "image/png"))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment