Commits

Alvaro Videla  committed 67a2ac0

sets file mime on save

  • Participants
  • Parent commits 991e989

Comments (0)

Files changed (1)

File src/resizer/resizer.clj

               (filename (cs/join ["small_" fname]))
               (metadata fmetadata)
               (content-type fctype)))
+(defn get-format [mime]
+  (last (.split mime "/")))
 
 (defn process-image
   "- Fetches image from gridfs and converts it to an ImageIO
    - Resizes the image.
    - Stores new image into gridfs with the small_ prefix"
-  [filename]
+  [filename mime]
   (let [original-image (image-from-input-stream filename)
-        resized-image (resize-image original-image width height)]
-    ;; TODO: enable other mime types
-    (save-file (buffimg-to-bytearray resized-image "jpg") filename {:format "jpg"} "image/jpg")))
+        resized-image (resize-image original-image width height)
+        img-byte-array (buffimg-to-bytearray resized-image (get-format mime))]
+    (save-file img-byte-array filename {:format (get-format mime)} mime)))