summaryrefslogtreecommitdiffstats
path: root/main.scm
diff options
context:
space:
mode:
authordan <[email protected]>2023-03-13 16:30:13 -0400
committerdan <[email protected]>2023-03-13 16:30:13 -0400
commit889c58413b613d234e880007966fc38b262d77e2 (patch)
tree29be552479d4c9f036aac9a02326356e0d1d0467 /main.scm
parent5f1f3fa55e998cd6021af7614275c3a1afb8b501 (diff)
download54-889c58413b613d234e880007966fc38b262d77e2.tar.gz
54-889c58413b613d234e880007966fc38b262d77e2.tar.bz2
54-889c58413b613d234e880007966fc38b262d77e2.zip
partial-fix: images not corrupted (but still not displaying with correct orientation)
Diffstat (limited to 'main.scm')
-rw-r--r--main.scm23
1 files changed, 14 insertions, 9 deletions
diff --git a/main.scm b/main.scm
index 2dce9b0..42bc2b4 100644
--- a/main.scm
+++ b/main.scm
@@ -1,5 +1,5 @@
(import
- scheme (chicken base) (chicken foreign)
+ scheme (chicken base) (chicken foreign) (chicken file posix)
(chicken format) (chicken port) (chicken io) (chicken random) (chicken time)
(chicken process-context) (chicken irregex) (chicken condition) (chicken blob)
spiffy intarweb uri-common html-parser spiffy-request-vars multipart-form-data
@@ -145,11 +145,18 @@
raw-img-vec
(u8vector-length raw-img-vec)))
-(define (set-exif-orientation! raw-img orientation)
- ((foreign-lambda void "setExifOrientation" blob unsigned-int unsigned-int)
- raw-img
- (blob-size raw-img)
- orientation))
+(define (set-exif-orientation raw-img orientation)
+ (let-values
+ ([(fd file-path) (file-mkstemp "/tmp/image-temp.XXXXXX")])
+ (file-write fd raw-img)
+ (file-close fd)
+ ((foreign-lambda void "setExifOrientation" nonnull-c-string unsigned-int)
+ file-path
+ orientation)
+ (let
+ ([port (open-input-file file-path #:binary)])
+ (u8vector->blob/shared (read-u8vector #f port)))
+ ))
(define dim-max 512)
@@ -185,11 +192,9 @@
target-height
channels)
)))])
- (set-exif-orientation! resized-jpg orientation)
- resized-jpg
+ (set-exif-orientation resized-jpg orientation)
)))
-
(define users (alist->hash-table '(("lawrence" . "pw") ("demo" . "pw") ("dan" . "pw"))))
(define apikeys (make-hash-table))