                   [:pre
                    {:id (str "frame-" i)
                     :style "font-size:5pt;line-height:5pt;letter-spacing:1px;font-weight:bold;display:none;font-family:monospace;"}
-                   (to-ascii (scale-image (.read ^ImageReader rdr i) w h))])
+                   (to-ascii (scale-image (.read ^ImageReader rdr i) w h) (+ h (* h w)))])
                (range frame-count))])
        :delay  (if (pos? frame-delay) frame-delay 10)
        :frames frame-count})))

        idx (if (zero? max-color) max-items (int (* max-items (/ max-color 255))))]
    (nth ascii (max idx 0))))

(defn to-ascii [^BufferedImage img]
  (let [width  (.getWidth img)
        height (.getHeight img)
        sb     (StringBuilder.)]
    (dotimes [y height]
      (dotimes [x width]
        (.append sb (ascii-color img y x)))

    (catch Exception _ 0)))

(defn gif->html [input]
  (let [rdr  ^ImageReader (.next (ImageIO/getImageReadersByFormatName "gif"))
        ciis (ImageIO/createImageInputStream input)]
    (.setInput rdr ciis false)    
    (let [frame-count (.getNumImages rdr true)
