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