[bknr-cvs] hans changed trunk/bknr/web/src/images/imageproc-handler.lisp
BKNR Commits
bknr at bknr.net
Thu Sep 18 06:12:23 UTC 2008
Revision: 3916
Author: hans
URL: http://bknr.net/trac/changeset/3916
When an image is being served unprocessed, send the blob data instead
of instantiating the image into memory and then serving it. This way,
the original picture quality will be preserved.
U trunk/bknr/web/src/images/imageproc-handler.lisp
Modified: trunk/bknr/web/src/images/imageproc-handler.lisp
===================================================================
--- trunk/bknr/web/src/images/imageproc-handler.lisp 2008-09-17 20:32:10 UTC (rev 3915)
+++ trunk/bknr/web/src/images/imageproc-handler.lisp 2008-09-18 06:12:23 UTC (rev 3916)
@@ -171,8 +171,13 @@
(error-404))
(defmethod handle-object ((page-handler imageproc-handler) image)
- (with-http-response (:content-type (image-content-type (image-type-keyword image)))
- (handle-if-modified-since (blob-timestamp image))
- (setf (header-out "Last-Modified") (rfc-1123-date (blob-timestamp image)))
- (imageproc image (cdr (decoded-handler-path page-handler)))))
+ (handle-if-modified-since (blob-timestamp image))
+ (setf (header-out :last-modified) (rfc-1123-date (blob-timestamp image)))
+ (let ((operations (cdr (decoded-handler-path page-handler))))
+ (if operations
+ (imageproc image operations)
+ (with-http-response (:content-type (image-content-type (image-type-keyword image)))
+ (setf (header-out :content-length) (blob-size image))
+ (with-open-file (blob-data (blob-pathname image) :element-type '(unsigned-byte 8))
+ (copy-stream blob-data (send-headers) '(unsigned-byte 8)))))))
More information about the Bknr-cvs
mailing list