Increase the image quality #17

This commit is contained in:
Aaron Fischer 2017-05-02 21:53:33 +02:00
parent 5bfb5c1c2f
commit 0d6662d093

View file

@ -3,6 +3,8 @@
[image-resizer.util :as utils]
[image-resizer.format :refer :all]
[image-resizer.crop :refer :all]
[image-resizer.resize :refer :all]
[image-resizer.scale-methods :refer :all]
[clojure.java.io :as io]
[digest :as digest]
[me.raynes.fs :as fs]
@ -35,17 +37,17 @@
(defn scale-thumbnail [width]
#(let [image-file % [orig-width orig-height] (dimensions (utils/buffered-image image-file))]
(if (< orig-width orig-height)
(let [resized-img (resize-to-width image-file width)
(let [resized-img ((resize-width-fn width ultra-quality) image-file)
[w h] (dimensions resized-img)
crop-margin (quot (- h width) 2)]
(crop-from resized-img 0 crop-margin width width))
(let [resized-img (resize-to-height image-file width)
(let [resized-img ((resize-height-fn width ultra-quality) image-file)
[w h] (dimensions resized-img)
crop-margin (quot (- w width) 2)]
(crop-from resized-img crop-margin 0 width width)))))
(defn scale-normal [width height]
#(resize % width height))
(resize-fn width height ultra-quality))
(defn save [fn params filepath target-filepath]
(let [file (exif/without-exif (io/file filepath))]