#!/bin/bash # doc gen_cover { # # DESCRIPTION # gen_cover - Generate cover image # # USAGE # gen_cover # # } gen_cover() { 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" "${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 return 0 }