From d75c7970265194645848af9d5c7535ebb3ea3d18 Mon Sep 17 00:00:00 2001 From: ange Date: Sun, 14 Apr 2024 13:53:40 +0200 Subject: [PATCH] feat: graphicsmagick support --- compress | 11 +++++++++-- test.sh | 7 ++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/compress b/compress index 2c3c6f8..12c8460 100755 --- a/compress +++ b/compress @@ -18,14 +18,21 @@ function compress() {( newdir="${PWD%/*}/$(basename "$dir")_1080p" mkdir -p "$newdir" for file in *; do - identify "$file" 2> /dev/null >&2 \ - && convert -resize x1080 "$file" "$newdir/$file" & + "${IDENTIFY[@]}" "$file" 2> /dev/null >&2 \ + && "${CONVERT[@]}" -resize x1080 "$file" "$newdir/$file" & wait_queue nb="$(printf '%s\n' "$newdir"/* | wc -l)" echo "$((nb * 100 / total))" done )} +IDENTIFY=(identify) +CONVERT=(convert) +if command -v gm > /dev/null; then + IDENTIFY=(gm "${IDENTIFY[@]}") + CONVERT=(gm "${CONVERT[@]}") +fi + if [ -z "$1" ]; then set "$(zenity --file-selection --multiple --directory --separator=' ')" > /dev/null diff --git a/test.sh b/test.sh index f39c7ae..a76da86 100755 --- a/test.sh +++ b/test.sh @@ -1,7 +1,12 @@ #!/bin/bash -e +CONVERT=(convert) +if command -v gm > /dev/null; then + CONVERT=(gm "${CONVERT[@]}") +fi + mkdir -p test test_1080p -gm convert -size 3840x2160 xc:black test/000.png +"${CONVERT[@]}" -size 3840x2160 xc:black test/000.png printf '%s\n' {001..127} | xargs -P0 -I'{}' cp test/000.png test/'{}'.png