Created
November 2, 2011 19:54
-
-
Save PaulSandoz/1334699 to your computer and use it in GitHub Desktop.
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
(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