generate-icons.cljs 1.01 KB
Newer Older
1
#!/usr/local/bin/planck
2
(ns relevance.generate-icons
3 4 5 6
  (:require [planck.core :refer [exit *command-line-args*]]
            [planck.shell :refer [sh]]))

(defn ensure-succeeded! [x]
7 8 9 10 11
      (print (:out x))
      (when-not (zero? (:exit x))
                (println "Non-zero exit code!")
                (print (:err x))
                (exit (:exit x))))
12 13 14


(defn do! [& args]
15 16
      (ensure-succeeded! (apply sh args)))

17 18
(def src-path "resources/")
(def dst-path "resources/images/")
19 20 21
(def sizes [16 19 38 48 128])

(defn do-resize! [filename]
22
      (doseq [size sizes]
23 24
             (let [origin (str src-path filename)
                   target (str dst-path "icon" size ".png")]
25 26 27
                  (println "Converting" origin "to" target)
                  (do! "convert" origin "-resize" (str size "x" size) target)
                  )))
28 29 30


(let [filename (first *command-line-args*)]
31 32 33
     (if (empty? filename)
       (println "Need a file name for the image to proceed. Aborting.")
       (do-resize! filename)))
34 35

(println "Done")