From 8b3ae7ac0b987edfab1ae7bb07f7b4d13b0e2ed4 Mon Sep 17 00:00:00 2001 From: Tony Tkacik Date: Thu, 28 Nov 2019 12:20:36 +0100 Subject: [PATCH] Use graphicsmagick if possible. Signed-off-by: Tony Tkacik --- bin/tdm-media | 8 +++++--- inc/thumby.inc.sh | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/bin/tdm-media b/bin/tdm-media index 3abe5d3..de51f8d 100755 --- a/bin/tdm-media +++ b/bin/tdm-media @@ -1,7 +1,9 @@ #!/usr/bin/env nuxr-nuxsh + type ffmpeg > /dev/null 2>&1 && FFMPEG_OR_LIBAV=ffmpeg type avconv > /dev/null 2>&1 && FFMPEG_OR_LIBAV=avconv +type gm /dev/null 2>&1 && NUX_MAGICK=gm QUALITY=${QUALITY:=90} @@ -36,10 +38,10 @@ QUALITY=${QUALITY:=90} target_file="${target_dir}/$name"; fi echo "Image: $i/$count Downsampling $image -> $target_file" - convert $image \ + $NUX_MAGICK convert $image \ -filter Lanczos -sampling-factor 1x1 \ -resize "${SIZE}x${SIZE}>" \ - -quality 90 \ + -quality $QUALITY \ $target_file done } @@ -66,5 +68,5 @@ QUALITY=${QUALITY:=90} } function media.to.jpg { - convert "$1" -quality $QUALITY -auto-orient "$2" + $NUX_MAGICK convert "$1" -quality $QUALITY -auto-orient "$2" } diff --git a/inc/thumby.inc.sh b/inc/thumby.inc.sh index 86ceb04..fe3e43c 100644 --- a/inc/thumby.inc.sh +++ b/inc/thumby.inc.sh @@ -1,5 +1,7 @@ nux.use nux.mime +type gm /dev/null 2>&1 && NUX_MAGICK=gm + function thumby.name.shared() { echo $(basename "$1"|md5sum|cut -d " " -f1).png } @@ -81,7 +83,7 @@ function thumby.thumb.get() { $preexec "$path" nux.log info "Source is : $source, Streamer is $streamer"; - $streamer "$path" | convert -thumbnail '256x256>' -strip "$source" "$thumbpath" >&2 + $streamer "$path" | $NUX_MAGICK convert -thumbnail '256x256>' -strip "$source" "$thumbpath" >&2 $postexec "$path" echo $thumbpath; fi @@ -89,7 +91,7 @@ function thumby.thumb.get() { } function thumby.thumb.generate() { - convert -thumbnail '256x256>' -strip "$path" "$thumbpath" >&2 + $NUX_MAGICK convert -thumbnail '256x256>' -strip "$path" "$thumbpath" >&2 } function thumby.get.thumb() {