If a jpg image has a quality setting, it can be extracted by using
convert image -format "%Q" info:
see
http://www.imagemagick.org/script/escape.php
A value of 0 means the default, which is either the input quality or 92 if no quality is set.
see
http://www.imagemagick.org/script/comma ... hp#quality
The result of the command can be put into a variable and tested against your limit and the result can be used for each image.
Example (unix syntax) -- assumes quality is an integer and not float value.
# create jpg with 80 quality
convert rose: -quality 80 rose_q80.jpg
# get quality and put into variable
qual=`convert rose_q80.jpg -format "%Q" info:`
echo $qual
80
# test if 0 or if greater than 96 and process image
if [ "$qual" -eq "0" ]; then
convert rose_q80.jpg -quality 92 rose_q96.jpg
elif [ $qual -gt 96 ]; then
convert rose_q80.jpg -quality 96 rose_q96.jpg
fi
The above will only set the quality to 96 if it is bigger than 96. Otherwise, it leaves the image unchanged or applies the default 92 to any jpg with no quality setting. You can set the default value to anything you want, when a zero value is returned.