dam/src/gen_cover

25 lines
592 B
Text
Raw Normal View History

2018-04-08 19:54:21 +00:00
#!/bin/bash
# doc gen_cover {
#
# DESCRIPTION
# gen_cover - Generate cover image
#
# USAGE
# gen_cover </path/to/cover/image>
2018-04-08 19:54:21 +00:00
#
# }
gen_cover() {
local COVER="${1}"
[[ ! -f "${COVER}" ]] && { convert -size 480x480 xc:white "${COVER}"; local ERROR=1; }
cat "${COVER}"
2018-04-08 19:54:21 +00:00
[[ ${ERROR} -eq 1 ]] && return 1
local IMG_SIZE="$(identify -format "%wx%h" "${COVER}")"
2018-04-08 19:54:21 +00:00
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
return 0
}