From f2922581c850c2b63fab05589e9a1774c5cbd9bc Mon Sep 17 00:00:00 2001 From: dbroqua Date: Sun, 23 Feb 2020 10:45:37 +0100 Subject: [PATCH] Fixed bug on file with space and optimize png --- resizePictures.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/resizePictures.sh b/resizePictures.sh index 7a1ed4d..7102b01 100755 --- a/resizePictures.sh +++ b/resizePictures.sh @@ -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