[gen_cover] [gen_small_cover] Relativised functions

This commit is contained in:
ayakael 2018-07-18 05:28:08 -08:00
parent 73b48e98ba
commit 6e6880462d
No known key found for this signature in database
GPG key ID: 575626A4AE5F4026
2 changed files with 8 additions and 8 deletions

View file

@ -6,16 +6,16 @@
# gen_cover - Generate cover image # gen_cover - Generate cover image
# #
# USAGE # USAGE
# gen_cover </path/to/import/folder> # gen_cover </path/to/cover/image>
# #
# } # }
gen_cover() { gen_cover() {
local FOLDER="${1}" local COVER="${1}"
[[ -f "${FOLDER}/folder.png" ]] || { convert -size 480x480 xc:white "${FOLDER}/folder.png"; local ERROR=1; } [[ -f "${COVER}" ]] || { convert -size 480x480 xc:white "${COVER}"; local ERROR=1; }
cat "${FOLDER}/folder.png" cat "${COVER}"
[[ ${ERROR} -eq 1 ]] && return 1 [[ ${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_WIDTH=$(echo ${IMG_SIZE} | cut -dx -f1)
local IMG_HEIGHT=$(echo ${IMG_SIZE} | cut -dx -f2) local IMG_HEIGHT=$(echo ${IMG_SIZE} | cut -dx -f2)
if [[ ${IMG_WIDTH} -lt 480 ]] && [[ ${IMG_HEIGHT} -lt 480 ]]; then return 2; fi if [[ ${IMG_WIDTH} -lt 480 ]] && [[ ${IMG_HEIGHT} -lt 480 ]]; then return 2; fi

View file

@ -11,10 +11,10 @@
# } # }
gen_small_cover() { gen_small_cover() {
local FOLDER="${1}" local COVER="${1}"
convert ${FOLDER}/folder.png -resize 480x480^ -gravity center ${FOLDER}/folder.jpg convert "${COVER}" -resize 480x480^ -gravity center "$(sed 's|.png|.jpg|' <<<${COVER})"
local EXIT=$? local EXIT=$?
cat "${FOLDER}/folder.jpg" cat "$(sed 's|.png|.jpg|' <<<${COVER})"
[[ ${EXIT} -ne 0 ]] && return 1 [[ ${EXIT} -ne 0 ]] && return 1
return 0 return 0
} }