Currently im using this command in terminal to compress a single image with imagemagick:
./convert_with_logging photo.jpg -quality 50% photo2.jpg
convert_with_logging is a script that contains:
INPUT_FILENAME="$1"
OUTPUT_FILENAME="$4"
ORIGINAL_SIZE=$(wc -c "${INPUT_FILENAME}" | cut -d ' ' -f1)
convert "$@"
COMPRESSED_SIZE=$(wc -c "${OUTPUT_FILENAME}" | cut -d ' ' -f1)
echo "${OUTPUT_FILENAME} | saved size: $(expr $ORIGINAL_SIZE - $COMPRESSED_SIZE)"
Note: this script converts and it also log the compressed size (ex: imageA.jpg | saved size: 1994825 )
Now currently im using this command to compress multiple images (that are jpg and jpeg):
for PHOTO in /home/dvs/Desktop/proj1/src/images/*.{jpeg,jpg}
do
BASE=`basename $PHOTO`
./convert_with_logging "$PHOTO" -quality 40% "/home/dvs/Desktop/proj1/src/compressed/$BASE"
done;
Now how can i convert all this last command in order to type "./convert_multi_with_logging" and get the same result?
I think that we need to add something like this to the script:
inpath="/home/dvs/Desktop/proj1/src/images/"
outpath="/home/dvs/Desktop/proj1/src/compressed/"