Fixed bug on file with space and optimize png

This commit is contained in:
dbroqua 2020-02-23 10:45:37 +01:00
parent b0b7b19c1a
commit f2922581c8

View file

@ -60,8 +60,8 @@ for image in {*.jpg,*.JPG} ; do
fi
# Extract image dimensions
WIDTH=`identify -format "%[fx:w]" ${image}`
HEIGHT=`identify -format "%[fx:h]" ${image}`
WIDTH=`identify -format "%[fx:w]" "${image}"`
HEIGHT=`identify -format "%[fx:h]" "${image}"`
# Compute image ratio
TMPIMAGERATIO=`bc -l <<< "${WIDTH}/${HEIGHT}"`
@ -95,13 +95,13 @@ for image in {*.jpg,*.JPG} ; do
echo -e "${GREEN}Converting cover file${RESET}"
# Crop image with the good ratio
convert -gravity Center -crop ${NEWWIDTH}x${NEWHEIGHT}+0+0 +repage ${image} /tmp/${image}
convert -gravity Center -crop ${NEWWIDTH}x${NEWHEIGHT}+0+0 +repage "${image}" "/tmp/${image}"
# Rezise cover and save it
convert ${OPTIONS} -resize ${COVERWIDTH}x${COVERHEIGHT} /tmp/${image} ${DEST}/${image}
convert ${OPTIONS} -resize ${COVERWIDTH}x${COVERHEIGHT} "/tmp/${image}" "${DEST}/${image}"
# Remove temporary file
rm /tmp/${image}
rm "/tmp/${image}"
else
echo -e "${RED}Converting image ${image}${RESET}"
echo -e " -> ${BLUE}Create JPG version${RESET}"
@ -144,6 +144,8 @@ for image in {*.jpg,*.JPG} ; do
# Add logo on imagedow
composite ${OPTIONS} -gravity SouthEast "${LOGO}" "${DEST}/${filename}.png" "${DEST}/${filename}.png"
convert "${DEST}/${filename}.png" -type TrueColorAlpha -quality 90 -format PNG32 -background transparent -depth 8 -strip "${DEST}/${filename}.png"
fi
fi
done