From 68ee12d2cfd7fd00162342e63774876b59b9b215 Mon Sep 17 00:00:00 2001 From: Aaron Fischer Date: Wed, 3 May 2017 23:17:47 +0200 Subject: [PATCH] Don't scale small images #14 --- src/clj/yenu/helpers/images.clj | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/clj/yenu/helpers/images.clj b/src/clj/yenu/helpers/images.clj index 7c24855..1bd94bc 100644 --- a/src/clj/yenu/helpers/images.clj +++ b/src/clj/yenu/helpers/images.clj @@ -48,7 +48,10 @@ (crop-from resized-img crop-margin 0 width width))))) (defn scale-normal [width height] - (resize-fn width height ultra-quality)) + #(let [image-file % [orig-width orig-height] (dimensions (utils/buffered-image image-file))] + (if (and (< orig-width width) (< orig-height height)) + ((resize-fn orig-width orig-height ultra-quality) %) + ((resize-fn width height ultra-quality) %)))) (defn remove-metadata [filepath file] (if (contains? #{".jpg" ".jpeg" ".jpe"} (s/lower-case (fs/extension filepath)))