Skip to content
This repository has been archived by the owner on Sep 14, 2022. It is now read-only.

Commit

Permalink
Pass gifsicle opts from wrapper shell script
Browse files Browse the repository at this point in the history
  • Loading branch information
ku1ik committed Apr 5, 2018
1 parent 12bb518 commit 24b4c30
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
4 changes: 4 additions & 0 deletions asciicast2gif
Expand Up @@ -96,6 +96,10 @@ if [[ -n $height ]]; then
export HEIGHT=$height
fi

if [[ -z $GIFSICLE_OPTS ]]; then
export GIFSICLE_OPTS="-k 64 -O2 -Okeep-empty"
fi

tmp_dir=$(mktemp -d 2>/dev/null || mktemp -d -t 'asciicast2gif-tmp')
trap 'rm -rf $tmp_dir' EXIT

Expand Down
17 changes: 11 additions & 6 deletions src/asciinema/gif/main.cljs
Expand Up @@ -123,16 +123,20 @@
(map reverse)
(mapcat single-frame-args)))

(defn- full-cmd [args out-path]
(defn- full-cmd [args out-path gifsicle-opts]
(str "convert -loop 0 "
(str/join " " args)
" -layers Optimize gif:- | gifsicle -k 64 -O2 -Okeep-empty -o "
" -layers Optimize gif:- | gifsicle "
gifsicle-opts
" -o "
out-path
" -"))

(defn- gen-gif [delays-and-paths out-path]
(log/info "Combining screenshots into GIF file...")
(let [cmd (-> delays-and-paths all-frame-args (full-cmd out-path))]
(defn- gen-gif [delays-and-paths out-path gifsicle-opts]
(log/info (str "Combining "
(count delays-and-paths)
" screenshots into GIF file..."))
(let [cmd (-> delays-and-paths all-frame-args (full-cmd out-path gifsicle-opts))]
(log/debug "Executing:" cmd)
(shell cmd)))

Expand All @@ -145,6 +149,7 @@
speed (js/parseFloat speed)
forced-width (aget env "WIDTH")
forced-height (aget env "HEIGHT")
gifsicle-opts (aget env "GIFSICLE_OPTS")
{:keys [width height frames]} (<? (load-asciicast url))
width (or forced-width width)
height (or forced-height height)
Expand All @@ -154,6 +159,6 @@
delays-and-paths (gen-image-frames renderer tmp-dir frames)]
(close-stdin renderer)
(<? (wait-for-exit renderer))
(gen-gif delays-and-paths out-path))))
(gen-gif delays-and-paths out-path gifsicle-opts))))

(set! *main-cli-fn* -main)

0 comments on commit 24b4c30

Please sign in to comment.