Detect JPEG image quality

后端 未结 7 878
借酒劲吻你
借酒劲吻你 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-10 10:35

    For those who are using GraphicsMagick instead of ImageMagick, you can get the JPEG quality with the following command:

    gm identify -format '%[JPEG-Quality]' path_to/image_file.jpg
    

    and according to the documentation http://www.graphicsmagick.org/GraphicsMagick.html#details-format

    Please note that JPEG has no notion of "quality" and that the quality metric used by, and estimated by the software is based on the quality metric established by IJG JPEG 6b. Other encoders (e.g. that used by Adobe Photoshop) use different encoding metrics.

提交回复
热议问题