Skip to content

Commit

Permalink
Remove multirow montage code
Browse files Browse the repository at this point in the history
There actually wasn't any point to it other than historically we
didn't need a loop to montage each row. That meant duplicate code and
sometimes lsix of fewer images would seem to start more slowly than
lsix of more images. Now images should start appearing immediately no
matter how many there are to show.
  • Loading branch information
hackerb9 committed Aug 25, 2018
1 parent a0e1781 commit ff88168
Showing 1 changed file with 13 additions and 28 deletions.
41 changes: 13 additions & 28 deletions lsix
Original file line number Diff line number Diff line change
Expand Up @@ -142,36 +142,21 @@ main() {
[[ "$fontfamily" ]] && imoptions+=" -font $fontfamily "
[[ "$fontsize" ]] && imoptions+=" -pointsize $fontsize "

if [[ $# -le 21 ]]; then
# Create an array of all filenames, interleaved with "-label:filename"
# E.g., '-label "foo"' 'foo.png' '-label "bar"' 'bar.jpg'
declare -a labeledfiles
i=0
for arg; do
labeledfiles[i++]="-label"
labeledfiles[i++]="$(processlabel "$arg")"
labeledfiles[i++]="$arg$resize"
# Create and display montages one row at a time.
while [ $# -gt 0 ]; do
# While we still have images to process...
onerow=()
goal=$(($# - numtiles)) # How many tiles left after this row
while [ $# -gt 0 -a $# -gt $goal ]; do
len=${#onerow[@]}
onerow[len++]="-label"
onerow[len++]=$(processlabel "$1")
onerow[len++]="$1"
shift
done
# Only a few pictures to show, do it in one (multipage) chunk.
montage "${labeledfiles[@]}" $imoptions gif:- \
montage "${onerow[@]}" $imoptions gif:- \
| convert - -colors $numcolors sixel:-
else
# Lots of pictures, so show them a row at a time instead
# of taking a long time to make one huge montage.
while [ $# -gt 0 ]; do
onerow=()
goal=$(($# - numtiles)) # How many tiles left after this row
while [ $# -gt 0 -a $# -gt $goal ]; do
len=${#onerow[@]}
onerow[len++]="-label"
onerow[len++]=$(processlabel "$1")
onerow[len++]="$1"
shift
done
montage "${onerow[@]}" $imoptions gif:- \
| convert - -colors $numcolors sixel:-
done
fi
done
}

processlabel() {
Expand Down

0 comments on commit ff88168

Please sign in to comment.