I am working on one of my project where user will upload the image. The uploaded image will be displayed using lightbox.
The problem is that user may upload an image of size say 5mb and so on. Because of this it takes large loading time. So I thought to reduce quality of image keeping the dimension same.
I know that we can use, imagejpeg() function, and pass third parameter which is quality say 90, that also reduces file size.
I need all image file size to be max 1mb, not more than that.
So, I am confused in what value should be pass as quality, so as to have optimum quality.
For eg. if uploaded image file size is 1.2mb, then say I will pass 90 as quality, that may bring down the size to less that 1mb, and also quality will be acceptable. Another case if uploaded file size is say 5mb, than if I pass 90 as quality, then file-size may not be less than 1mb. Here I need to pass less quality value (I guess).
So is there any method that helps me in determining optimum quality parameter that should be passed.
Many thanks for your time.