[gen_cover] [gen_small_cover] Relativised functions
This commit is contained in:
parent
73b48e98ba
commit
6e6880462d
2 changed files with 8 additions and 8 deletions
|
@ -6,16 +6,16 @@
|
|||
# gen_cover - Generate cover image
|
||||
#
|
||||
# USAGE
|
||||
# gen_cover </path/to/import/folder>
|
||||
# gen_cover </path/to/cover/image>
|
||||
#
|
||||
# }
|
||||
|
||||
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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue