Added PNG version with box-shadow

This commit is contained in:
dbroqua 2018-10-07 18:32:35 +02:00
parent bc396d9d8f
commit b0b7b19c1a

View file

@ -104,6 +104,7 @@ for image in {*.jpg,*.JPG} ; do
rm /tmp/${image} rm /tmp/${image}
else else
echo -e "${RED}Converting image ${image}${RESET}" echo -e "${RED}Converting image ${image}${RESET}"
echo -e " -> ${BLUE}Create JPG version${RESET}"
# Compute positions for black border # Compute positions for black border
BORDERUPPERLEFT=$((${BORDERWIDTH}/2)),$((${BORDERWIDTH}/2)) BORDERUPPERLEFT=$((${BORDERWIDTH}/2)),$((${BORDERWIDTH}/2))
@ -120,12 +121,29 @@ 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 ${BORDERUPPERLEFT} 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'" \
"${DEST}/${image}" "${DEST}/${image}"
# Add logo on imagedow # Add logo on imagedow
composite ${OPTIONS} -gravity SouthEast "${LOGO}" "${DEST}/${image}" "${DEST}/${image}" composite ${OPTIONS} -gravity SouthEast "${LOGO}" "${DEST}/${image}" "${DEST}/${image}"
# Create same version but in PNG and with box shadow
echo -e " -> ${BLUE}Create PNG version${RESET}"
filename=$(basename -- "${image}")
extension="${filename##*.}"
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 \
"${DEST}/${filename}.png"
# Add logo on imagedow
composite ${OPTIONS} -gravity SouthEast "${LOGO}" "${DEST}/${filename}.png" "${DEST}/${filename}.png"
fi fi
fi fi
done done