Fixed bug for cover

This commit is contained in:
dbroqua 2021-06-11 12:02:08 +02:00
parent d23cc0079f
commit df603da5f8

View file

@ -50,10 +50,10 @@ RESET="\033[0m"
# If destination does not exists, create it # If destination does not exists, create it
if [ ! -d ${DESTJPG} ] ; then if [ ! -d ${DESTJPG} ] ; then
mkdir -p ${DESTJPG} mkdir -p ${DESTJPG}
fi fi
if [ ! -d ${DESTPNG} ] ; then if [ ! -d ${DESTPNG} ] ; then
mkdir -p ${DESTPNG} mkdir -p ${DESTPNG}
fi fi
# For each files # For each files
@ -84,7 +84,7 @@ for image in {*.jpg,*.JPG} ; do
# Compute new image size based on image type # Compute new image size based on image type
if [ "${image}" == "${COVERFILE}" ] ; then if [ "${image}" == "${COVERFILE}" ] ; then
# Compute temporary with or height to crop correctly image # Compute temporary with or height to crop correctly image
if [ "${COVERRATIO}" -gt "${TMPIMAGERATIO}" ] ; then if (( $(echo "${COVERRATIO} >= ${TMPIMAGERATIO}" | bc -l) )) ; then
NEWHEIGHT=$((${WIDTH}*${COVERHEIGHT}/${COVERWIDTH})) NEWHEIGHT=$((${WIDTH}*${COVERHEIGHT}/${COVERWIDTH}))
else else
NEWWIDTH=$((${HEIGHT}*${COVERWIDTH}/${COVERHEIGHT})) NEWWIDTH=$((${HEIGHT}*${COVERWIDTH}/${COVERHEIGHT}))
@ -131,10 +131,10 @@ for image in {*.jpg,*.JPG} ; do
# resize and add border on image # resize and add border on image
convert -resize ${NEWWIDTH}x${NEWHEIGHT} \ convert -resize ${NEWWIDTH}x${NEWHEIGHT} \
"${image}" \ "${image}" \
-fill transparent -stroke black -strokewidth ${BORDERWIDTH} -draw "stroke-linecap square path 'M $((${BORDERWIDTH}/2)),0 L ${BORDERLOWERLEFT} L ${BORDERLOWERRIGHT} L ${BORDERUPPERRIGHT} L ${BORDERUPPERLEFT} Z'" \ -fill transparent -stroke black -strokewidth ${BORDERWIDTH} -draw "stroke-linecap square path 'M $((${BORDERWIDTH}/2)),0 L ${BORDERLOWERLEFT} L ${BORDERLOWERRIGHT} L ${BORDERUPPERRIGHT} L ${BORDERUPPERLEFT} Z'" \
-fill transparent -stroke white -strokewidth ${BORDERTHINWIDTH} -draw "stroke-linecap square path 'M ${THINBORDERUPPERLEFT} L ${THINBORDERLOWERLEFT} L ${THINBORDERLOWERRIGHT} L ${THINBORDERUPPERRIGHT} L ${THINBORDERUPPERLEFT} Z'" \ -fill transparent -stroke white -strokewidth ${BORDERTHINWIDTH} -draw "stroke-linecap square path 'M ${THINBORDERUPPERLEFT} L ${THINBORDERLOWERLEFT} L ${THINBORDERLOWERRIGHT} L ${THINBORDERUPPERRIGHT} L ${THINBORDERUPPERLEFT} Z'" \
"${DESTJPG}/${image}" "${DESTJPG}/${image}"
# Add logo on imagedow # Add logo on imagedow
composite ${OPTIONS} -gravity SouthEast "${LOGO}" "${DESTJPG}/${image}" "${DESTJPG}/${image}" composite ${OPTIONS} -gravity SouthEast "${LOGO}" "${DESTJPG}/${image}" "${DESTJPG}/${image}"
@ -146,12 +146,12 @@ for image in {*.jpg,*.JPG} ; do
filename="${filename%.*}" filename="${filename%.*}"
convert -resize ${NEWWIDTH}x${NEWHEIGHT} \ convert -resize ${NEWWIDTH}x${NEWHEIGHT} \
"${image}" \ "${image}" \
-fill transparent -stroke black -strokewidth ${BORDERWIDTH} -draw "stroke-linecap square path 'M $((${BORDERWIDTH}/2)),0 L ${BORDERLOWERLEFT} L ${BORDERLOWERRIGHT} L ${BORDERUPPERRIGHT} L ${BORDERUPPERLEFT} Z'" \ -fill transparent -stroke black -strokewidth ${BORDERWIDTH} -draw "stroke-linecap square path 'M $((${BORDERWIDTH}/2)),0 L ${BORDERLOWERLEFT} L ${BORDERLOWERRIGHT} L ${BORDERUPPERRIGHT} L ${BORDERUPPERLEFT} Z'" \
-fill transparent -stroke white -strokewidth ${BORDERTHINWIDTH} -draw "stroke-linecap square path 'M ${THINBORDERUPPERLEFT} L ${THINBORDERLOWERLEFT} L ${THINBORDERLOWERRIGHT} L ${THINBORDERUPPERRIGHT} L ${THINBORDERUPPERLEFT} Z'" \ -fill transparent -stroke white -strokewidth ${BORDERTHINWIDTH} -draw "stroke-linecap square path 'M ${THINBORDERUPPERLEFT} L ${THINBORDERLOWERLEFT} L ${THINBORDERLOWERRIGHT} L ${THINBORDERUPPERRIGHT} L ${THINBORDERUPPERLEFT} Z'" \
\( +clone -background black -shadow 80x3+2+2 \) \ \( +clone -background black -shadow 80x3+2+2 \) \
+swap -background transparent -layers merge +repage \ +swap -background transparent -layers merge +repage \
"${DESTPNG}/${filename}.png" "${DESTPNG}/${filename}.png"
# Add logo on imagedow # Add logo on imagedow
composite ${OPTIONS} -gravity SouthEast "${LOGO}" "${DESTPNG}/${filename}.png" "${DESTPNG}/${filename}.png" composite ${OPTIONS} -gravity SouthEast "${LOGO}" "${DESTPNG}/${filename}.png" "${DESTPNG}/${filename}.png"