From 6e6880462d8ef7991257d6e78bcda118f726db57 Mon Sep 17 00:00:00 2001 From: ayakael Date: Wed, 18 Jul 2018 05:28:08 -0800 Subject: [PATCH] [gen_cover] [gen_small_cover] Relativised functions --- src/gen_cover | 10 +++++----- src/gen_small_cover | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/gen_cover b/src/gen_cover index 4c28931..7c7ccec 100644 --- a/src/gen_cover +++ b/src/gen_cover @@ -6,16 +6,16 @@ # gen_cover - Generate cover image # # USAGE -# gen_cover +# gen_cover # # } gen_cover() { - local FOLDER="${1}" - [[ -f "${FOLDER}/folder.png" ]] || { convert -size 480x480 xc:white "${FOLDER}/folder.png"; local ERROR=1; } - cat "${FOLDER}/folder.png" + local COVER="${1}" + [[ -f "${COVER}" ]] || { convert -size 480x480 xc:white "${COVER}"; local ERROR=1; } + cat "${COVER}" [[ ${ERROR} -eq 1 ]] && return 1 - local IMG_SIZE="$(identify -format "%wx%h" "${FOLDER}/folder.jpg")" + local IMG_SIZE="$(identify -format "%wx%h" "${COVER}")" local IMG_WIDTH=$(echo ${IMG_SIZE} | cut -dx -f1) local IMG_HEIGHT=$(echo ${IMG_SIZE} | cut -dx -f2) if [[ ${IMG_WIDTH} -lt 480 ]] && [[ ${IMG_HEIGHT} -lt 480 ]]; then return 2; fi diff --git a/src/gen_small_cover b/src/gen_small_cover index d7a8ef0..2fe21b6 100644 --- a/src/gen_small_cover +++ b/src/gen_small_cover @@ -11,10 +11,10 @@ # } gen_small_cover() { - local FOLDER="${1}" - convert ${FOLDER}/folder.png -resize 480x480^ -gravity center ${FOLDER}/folder.jpg + local COVER="${1}" + convert "${COVER}" -resize 480x480^ -gravity center "$(sed 's|.png|.jpg|' <<<${COVER})" local EXIT=$? - cat "${FOLDER}/folder.jpg" + cat "$(sed 's|.png|.jpg|' <<<${COVER})" [[ ${EXIT} -ne 0 ]] && return 1 return 0 }