mybe this tool can help you to make the script ?
http://www.programmersheaven.com
i have try it and can pipe it out to a file:
jpgdump filename.jpg >filename.txt
and got like this:
007.jpg:
Approximate quality factor for qtable 0: 88 (scale 23.93, var 123.77)
Approximate quality factor for qtable 1: 91 (scale 18.13, var 120.25)
width 3236, height 2161 components 3
id 1 horizontal sampling 1, vertical sampling 1, quantization table 0
id 2 horizontal sampling 1, vertical sampling 1, quantization table 1
id 3 horizontal sampling 1, vertical sampling 1, quantization table 1
in the above i got ALL info i want...
Quality factor 0:88
with 3236x2161