paddy correctly, that this option is not always saved in the JPEG file. If so, you can use identify from Imagemagick to read quality. For instance:
$ identify -format '%Q' tornado_ok.jpg
93%
Update: based on the answer to this question https://superuser.com/questions/62730/how-to-find-the-jpg-quality, I that the identify team can still determine the quality by reverse engineering the quantization tables, even if the whole image EXIF / other metadata is lost. By the way, the title of your question now, is a possible duplication of this question with which I am associated.
But for me, your question has its merits, because in your question text you explain what you are trying to do, which is more than just determining the quality of jpeg. However, you should probably update the title if you want you to think that you are trying to solve a more specific problem than just reading a JPEG image.
If you do not archive the original images, even 90% is excessive for network use. 75% were standard in the old days (degradation was visible only with close inspection between images side by side), and now in days of high throughput 85% is a very high-quality option. The difference of 5% quality between 90% and 85% is almost invisible, but as a rule, it will save you more than 30%. The JPEG algorithm is designed to start by eliminating information that is not visible to humans in the first stages of compression (above 80% or so).
Update / note: the compression quality parameters I'm talking about are from tests with libjpeg, a very widely used JPEG library. in Photoshop, compression ratios and other software quality parameters are independent and do not necessarily mean the same as libjpeg settings.
The idea of using image height and image width to calculate the acceptable file size is reasonable:
You can get the height / width of the image as follows:
list($originalWidth, $originalHeight) = getimagesize($imageFile);
My own high-quality photos posted on the Internet, for example: http://ksathletics.com/2013/wsumbb/nw.jpg are usually stored at a ratio of about 200 KB per megapixel.
So, for example, you can multiply the width by height and divide by 1,000,000 to calculate megapixels in the image. Divide the file size by 1024 to calculate KB. Then divide the resulting KB by megapixels. If the result is less than 200 or any value that you decide, then you do not need to compress it again. Otherwise, you can re-compress it with 85% quality or whatever quality you decide.