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 [ ! -d ${DESTJPG} ] ; then
mkdir -p ${DESTJPG}
mkdir -p ${DESTJPG}
fi
if [ ! -d ${DESTPNG} ] ; then
mkdir -p ${DESTPNG}
mkdir -p ${DESTPNG}
fi
# For each files
@ -64,7 +64,7 @@ for image in {*.jpg,*.JPG} ; do
continue
fi
if [ `exiftool -Orientation -n "${image}" | cut -d":" -f2|cut -d' ' -f2` -eq 6 ] ; then
if [ `exiftool -Orientation -n "${image}" | cut -d":" -f2|cut -d' ' -f2` -eq 6 ] ; then
convert -auto-orient ${image} ${image}
fi
@ -84,7 +84,7 @@ for image in {*.jpg,*.JPG} ; do
# Compute new image size based on image type
if [ "${image}" == "${COVERFILE}" ] ; then
# 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}))
else
NEWWIDTH=$((${HEIGHT}*${COVERWIDTH}/${COVERHEIGHT}))
@ -128,13 +128,13 @@ for image in {*.jpg,*.JPG} ; do
THINBORDERLOWERLEFT=${BORDERTHINPLACEMENT},$((${NEWHEIGHT}-${BORDERTHINPLACEMENT} ))
THINBORDERLOWERRIGHT=$((${NEWWIDTH}-${BORDERTHINPLACEMENT} )),$((${NEWHEIGHT}-${BORDERTHINPLACEMENT} ))
THINBORDERUPPERRIGHT=$((${NEWWIDTH}-${BORDERTHINPLACEMENT} )),${BORDERTHINPLACEMENT}
# resize and add border on image
convert -resize ${NEWWIDTH}x${NEWHEIGHT} \
"${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 white -strokewidth ${BORDERTHINWIDTH} -draw "stroke-linecap square path 'M ${THINBORDERUPPERLEFT} L ${THINBORDERLOWERLEFT} L ${THINBORDERLOWERRIGHT} L ${THINBORDERUPPERRIGHT} L ${THINBORDERUPPERLEFT} Z'" \
"${DESTJPG}/${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 white -strokewidth ${BORDERTHINWIDTH} -draw "stroke-linecap square path 'M ${THINBORDERUPPERLEFT} L ${THINBORDERLOWERLEFT} L ${THINBORDERLOWERRIGHT} L ${THINBORDERUPPERRIGHT} L ${THINBORDERUPPERLEFT} Z'" \
"${DESTJPG}/${image}"
# Add logo on imagedow
composite ${OPTIONS} -gravity SouthEast "${LOGO}" "${DESTJPG}/${image}" "${DESTJPG}/${image}"
@ -146,12 +146,12 @@ for image in {*.jpg,*.JPG} ; do
filename="${filename%.*}"
convert -resize ${NEWWIDTH}x${NEWHEIGHT} \
"${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 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 \) \
+swap -background transparent -layers merge +repage \
"${DESTPNG}/${filename}.png"
"${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 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 \) \
+swap -background transparent -layers merge +repage \
"${DESTPNG}/${filename}.png"
# Add logo on imagedow
composite ${OPTIONS} -gravity SouthEast "${LOGO}" "${DESTPNG}/${filename}.png" "${DESTPNG}/${filename}.png"