Skip to content

Commit

Permalink
alias montage="magick montage" for IM7
Browse files Browse the repository at this point in the history
Montage is not deprecated, yet, but it looks like it is going to be.

Also, switched to using an alias (instead of a variable) for convert
as it looks cleaner. Downside is that if they don't have a sixel
terminal, the error message will tell users to type `convert` even for
IM7. For now, that's fine.

Perhaps of note about the return value of `type` and `command`:

       This command       |  Is equivalent to these commands
    ----------------------|----------------------------------
       type foo           |  command -v foo
       type foo bar       |  type foo  &&  type bar
       command -v foo bar |  command -v foo  ||  command -v bar

Therefore, `command -v magick montage` does an implicit "OR", which is
what we want when checking if either of IM6 or IM7 is installed.
  • Loading branch information
hackerb9 committed Jun 12, 2024
1 parent 2b7c9e7 commit 93d067a
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions lsix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# Requirements: just ImageMagick (and a Sixel terminal, of course)

# Version 1.9
# Version 1.9.1
# B9 June 2024

# See end of file for USAGE.
Expand Down Expand Up @@ -54,22 +54,20 @@ if [[ ${BASH_VERSINFO[0]} -eq 3 ]]; then
fi
fi

shopt -s expand_aliases # Allow aliases for working around quirks.

# For ImageMagick 6 <-> 7 compatibility.
magick=$(type -p magick)
if [[ ! $magick ]]; then
convert="convert"
else
convert="$magick"
if type magick &>/dev/null; then
alias convert='magick'
alias montage='magick montage'
fi

if ! command -v $magick montage >/dev/null; then
if ! command -v magick montage &>/dev/null; then # (implicit 'or')
echo "Please install ImageMagick" >&2
exit 1
fi

shopt -s expand_aliases # Allow aliases for working around quirks.

if command -v gsed >/dev/null; then
if type gsed &>/dev/null; then
alias sed=gsed # Use GNU sed for MacOS & BSD.
fi

Expand Down Expand Up @@ -107,7 +105,7 @@ autodetect() {
You may test your terminal by viewing a single image, like so:
$convert foo.jpg -geometry 800x480 sixel:-
convert foo.jpg -geometry 800x480 sixel:-
If your terminal actually does support sixel, please file a bug
report at http://github.com/hackerb9/lsix/issues
Expand Down Expand Up @@ -245,13 +243,13 @@ main() {
onerow[len++]="file://$1"
shift
done
$magick montage "${onerow[@]}" $imoptions gif:- \
| $convert - -colors $numcolors sixel:-
montage "${onerow[@]}" $imoptions gif:- \
| convert - -colors $numcolors sixel:-
done
}

processlabel() {
# This routine is all about appeasing ImageMagick.
# This routine is mostly to appease ImageMagick.
# 1. Remove silly [0] suffix and : prefix.
# 2. Quote percent backslash, and at sign.
# 3. Replace control characters with question marks.
Expand Down Expand Up @@ -308,7 +306,7 @@ read -s -t 60 -d "c" -p $'\e[c' >&2
# * If your terminal supports changing the number of color registers
# to improve the picture quality, lsix will do so.

# * Only software needed is ImageMagick (e.g., apt-get install imagemagick).
# * Only software needed is ImageMagick (e.g., apt install imagemagick).

# Your terminal must support SIXEL graphics. E.g.,
#
Expand Down

0 comments on commit 93d067a

Please sign in to comment.