Plaster
New
List
Login
common-lisp
default
anonymous
2024.04.06 08:44:53
(in-package #:zma.web) (defun gen-captcha (out) "outpath is either a stream of a pathname" (with-canvas (:width 120 :height 80) (clear-canvas) (set-font (get-font (rel-path "./static/fnt/liberation-sans.bold.ttf")) 16) (draw-string 10 10 "hello") ;; output image (save-png-stream out))) (import :lack.util.writer-stream) (defroute "/captcha" () (setf (getf (response-headers *response*) :content-type) "image/png") ;; TODO: write imagedata directly to output stream with #'gen-captcha ) ;; writing to file works fine (with-open-file (s (rel-path "./hello.png") :element-type '(unsigned-byte 8) :direction :output) (gen-captcha s))
Raw
Annotate
Repaste
Edit