add clojure functions to wrap reading/conversion of gif image frames
This commit is contained in:
parent
f813021fa8
commit
cc79193339
|
@ -73,4 +73,24 @@
|
|||
{:width (.getWidth final-image)
|
||||
:height (.getHeight final-image)
|
||||
:color? (if color? true false) ; forcing an explicit true/false because i am nitpicky like that
|
||||
:image (ImageToAscii/convert final-image color?)})))
|
||||
:image (ImageToAscii/convert final-image color?)})))
|
||||
|
||||
(defn- get-ascii-gif-frames [^ImageInputStream image-stream scale-to-width color?]
|
||||
(->> (AnimatedGif/read image-stream)
|
||||
(mapv
|
||||
(fn [^ImageFrame frame]
|
||||
(-> (.image frame)
|
||||
(convert-image scale-to-width color?)
|
||||
(assoc :delay (.delay frame)))))))
|
||||
|
||||
(defn convert-animated-gif-frames
|
||||
([^ImageInputStream image-stream color?]
|
||||
(convert-animated-gif-frames image-stream nil color?))
|
||||
([^ImageInputStream image-stream scale-to-width color?]
|
||||
(let [frames (get-ascii-gif-frames image-stream scale-to-width color?)
|
||||
width (-> frames first :width)
|
||||
height (-> frames first :height)]
|
||||
{:width width
|
||||
:height height
|
||||
:color? (if color? true false) ; forcing an explicit true/false because i am nitpicky like that
|
||||
:frames (mapv #(select-keys % [:image :delay]) frames)})))
|
||||
|
|
Loading…
Reference in a new issue