Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/io/perun.clj
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,11 @@

(defn resize-paths
"Returns a map of path -> input for images-resize"
[fileset {:keys [out-dir parent-path meta resolutions] :as options} tmp-dir]
[fileset {:keys [out-dir meta resolutions] :as options} tmp-dir]
(let [global-meta (pm/get-global-meta fileset)
files (boot/ls fileset)]
(reduce
(fn [result {:keys [slug path extension] :as entry}]
(fn [result {:keys [slug path extension parent-path] :as entry}]
(reduce
(fn [result* resolution]
(let [new-filename (str slug "_" resolution "." extension)
Expand Down Expand Up @@ -342,8 +342,7 @@
[image-resizer "0.1.10"]])

(def ^:private +images-resize-defaults+
{:out-dir "public"
:resolutions #{3840 2560 1920 1280 1024 640}
{:resolutions #{3840 2560 1920 1280 1024 640}
:filterer identity
:extensions [".png" ".jpeg" ".jpg"]})

Expand Down
25 changes: 17 additions & 8 deletions test/io/perun_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -115,26 +115,35 @@
:msg "`images-dimensions should add `:io.perun/images-dimensions` to `:io.perun/trace`")))

(deftesttask images-resize-test []
(comp (add-image :path "test-image.jpg" :type "JPG" :width 10 :height 10)
(comp (add-image :path "public/test-image-1.jpg" :type "JPG" :width 10 :height 10)
(add-image :path "public/images/test-image-2.jpg" :type "JPG" :width 10 :height 10)
(p/images-resize :resolutions #{100 200})
(value-check :path (perun/url-to-path "public/test-image_100.jpg")
(value-check :path (perun/url-to-path "test-image-1_100.jpg")
:value-fn #(meta= %1 %2 :width 100)
:msg "`images-resize resize image file and set `:width` metadata")
(value-check :path (perun/url-to-path "public/test-image_100.jpg")
(value-check :path (perun/url-to-path "test-image-1_100.jpg")
:value-fn #(meta= %1 %2 :height 100)
:msg "`images-resize resize image file and set `:height` metadata")
(value-check :path (perun/url-to-path "public/test-image_100.jpg")
(value-check :path (perun/url-to-path "test-image-1_100.jpg")
:value-fn #(meta-contains? %1 %2 :io.perun/trace :io.perun/images-resize)
:msg "`images-resize should add `:io.perun/images-resize` to `:io.perun/trace`")
(value-check :path (perun/url-to-path "public/test-image_200.jpg")
(value-check :path (perun/url-to-path "test-image-1_200.jpg")
:value-fn #(meta= %1 %2 :width 200)
:msg "`images-resize resize image file and set `:width` metadata")
(value-check :path (perun/url-to-path "public/test-image_200.jpg")
(value-check :path (perun/url-to-path "test-image-1_200.jpg")
:value-fn #(meta= %1 %2 :height 200)
:msg "`images-resize resize image file and set `:height` metadata")
(value-check :path (perun/url-to-path "public/test-image_200.jpg")
(value-check :path (perun/url-to-path "test-image-1_200.jpg")
:value-fn #(meta-contains? %1 %2 :io.perun/trace :io.perun/images-resize)
:msg "`images-resize should add `:io.perun/images-resize` to `:io.perun/trace`")))
:msg "`images-resize should add `:io.perun/images-resize` to `:io.perun/trace`")
(value-check :path (perun/url-to-path "public/images/test-image-2_100.jpg")
:value-fn #(meta= %1 %2 :width 100)
:msg "`images-resize resize image file and set `:width` metadata")
(add-image :path "public/images/test-image-3.jpg" :type "JPG" :width 10 :height 10)
(p/images-resize :resolutions #{100} :out-dir "public")
(value-check :path (perun/url-to-path "public/test-image-3_100.jpg")
:value-fn #(meta= %1 %2 :width 100)
:msg "`images-resize resize image file and set `:width` metadata")))

(deftask add-txt-file
[p path PATH str "path of the file to add"
Expand Down