Detect JPEG image quality

后端 未结 7 881
借酒劲吻你
借酒劲吻你 2021-02-10 10:25

I allow users to upload images. However, I want to keep JPEG quality not more than 90%. What I plan to do is to detect the current quality: - If less than 90% do nothing - If mo

7条回答
  •  臣服心动
    2021-02-10 10:56

    You cannot guarantee that the quality setting is stored in the JPEG's metadata. This is an encoder setting, not an image attribute.

    Read more here about estimating JPEG quality

    It might make more sense to simply define a maximum file size. At the end of the day, restricting image quality is all about saving bandwidth. So setting a ratio between image dimensions and file size is more appropriate.

提交回复
热议问题