Menu

#293 gm identify bug?

v1.0_(example)
closed-fixed
None
5
2015-03-10
2015-02-12
tumin
No

i use gm identify a picture,use the format "%Q" always show number is 75,but use verbose show the "JPEG-Quality: 88",attachment is the sample pic.

C:\Users\tu>gm identify -format %Q C:\Users\tu\Desktop\119.jpg
75

C:\Users\tu>gm identify -verbose C:\Users\tu\Desktop\119.jpg
Image: C:\Users\tu\Desktop\119.jpg
Format: JPEG (Joint Photographic Experts Group JFIF format)
Geometry: 139x134
Class: DirectClass
Type: true color
Depth: 8 bits-per-pixel component
Channel Depths:
Red: 8 bits
Green: 8 bits
Blue: 8 bits
Channel Statistics:
Red:
Minimum: 90.00 (0.3529)
Maximum: 255.00 (1.0000)
Mean: 246.26 (0.9657)
Standard Deviation: 22.74 (0.0892)
Green:
Minimum: 53.00 (0.2078)
Maximum: 255.00 (1.0000)
Mean: 228.57 (0.8963)
Standard Deviation: 31.40 (0.1231)
Blue:
Minimum: 2.00 (0.0078)
Maximum: 249.00 (0.9765)
Mean: 187.86 (0.7367)
Standard Deviation: 45.19 (0.1772)
Resolution: 72x72 pixels/inch
Filesize: 2.7K
Interlace: No
Orientation: Unknown
Background Color: white
Border Color: #DFDFDF
Matte Color: #BDBDBD
Page geometry: 139x134+0+0
Compose: Over
Dispose: Undefined
Iterations: 0
Compression: JPEG
JPEG-Quality: 88
JPEG-Colorspace: 2
JPEG-Colorspace-Name: RGB
JPEG-Sampling-factors: 2x2,1x1,1x1
Signature: 2f1d4b38fa9255e1fc89a7edd3f7f16037e32760c57eebe6971a8eedbe1e5307
Tainted: False

1 Attachments

Discussion

  • Glenn Randers-Pehrson

    Without the -verbose option, identify just "pings" the image (only reads the header), but it needs to read the entire image to determine the quality. A workaround is to do "gm identify -verbose file.jpg | grep Quality". I'll see about developing a better fix.

     
  • Glenn Randers-Pehrson

    • assigned_to: Glenn Randers-Pehrson
     
  • Glenn Randers-Pehrson

    Your test image actually has quality 75, not 88. I'm attaching a new test image which has quality 90.

     
  • Glenn Randers-Pehrson

    SF has done us a nice favor by reducing the quality of both of our images to 75.

    Try http://www.simplesystems.org/users/glennrp/GM/Quality/

     

    Last edit: Glenn Randers-Pehrson 2015-02-19
  • Bob Friesenhahn

    Bob Friesenhahn - 2015-02-22

    Regardless of SF's "improvements" to the image, it is useful to know that identify -format %Q only returns quality from the image structure and not from the JPEG-specific "JPEG-Quality" text attribute. If the JPEG reader would automatically update the image properties (quality and sampling) when the file is read, then %Q would reflect it. The "JPEG-Quality" text attribute is only an estimate (based in IJG JPEG library behavior) though since JPEG itself has no notion of a quality factor.

     
  • VdF

    VdF - 2015-03-09

    Hi,
    I have the same problem as Tumin. Even if I understand Bob's arguments (at least I try to), the lambda user expects the same behaviour from -format %Q and identify -verbose "JPEG-Quality". I think it is the meaning of tumin's post.
    Is it possible that the 2 functions give the same result or must we always use identify -verbose ?
    Thanks

     
  • Glenn Randers-Pehrson

    It could be done but it's not trivial. The JPEG decoder is not allowed to write into the "image_info" struct, so we'd need to add a "quality" member to the "image" structure. Then we'd have two "quality" numbers and need to figure out which to show. I think "image_info->quality" would be the "desired quality" and "image->quality" would be the quality estimated from the input.

    There would be side effects felt by all other image formats. What happens when someone converts a JPEG to PNG or vice versa, where "quality" has entirely different meanings, and could come either from the input image or from a user request? Bob, do you mind if we add a "quality" member to the "image" structure? There's already a comment there to suggest it for some "Future" version.

    For now, use identify -verbose.

     
    • Bob Friesenhahn

      Bob Friesenhahn - 2015-03-09

      On Mon, 9 Mar 2015, Glenn Randers-Pehrson wrote:

      There would be side effects felt by all other image formats. What happens when someone converts a JPEG to PNG or
      vice versa, where "quality" has entirely different meanings, and could come either from the input image or from a
      user request? Bob, do you mind if we add a "quality" member to the "image" structure? There's already a comment
      there to suggest it for some "Future" version.

      I don't think that we can add new Image members without changing the
      ABI and necessitating a new major point release cycle. If we were to
      do that, then quite a lot more changes would be in order.

      It is likely not difficult to add special support when the format just
      read ('magick') is JPEG or equivalent. This would of course be a
      user-visible change since values would change.

      Unless the estimated quality is then used to save any written JPEG
      files, users would be even more confused.

      Bob

       
    • Bob Friesenhahn

      Bob Friesenhahn - 2015-03-10

      On Mon, 9 Mar 2015, Glenn Randers-Pehrson wrote:

      For now, use identify -verbose.

      That is not necessary. This command produces the desired output and
      is very fast:

         gm identify -format "%[JPEG-Quality]" ~/seaworld.jpg
         90
      

      or for all the related parameters

         gm identify -format "%[JPEG-*]" ~/seaworld.jpg
         JPEG-Quality=90
         JPEG-Colorspace=2
         JPEG-Colorspace-Name=RGB
         JPEG-Sampling-factors=2x2,1x1,1x1
      
       
      • VdF

        VdF - 2015-03-10

        That is not necessary. This command produces the desired output and
        is very fast:

        gm identify -format "%[JPEG-Quality]" ~/seaworld.jpg
        90

        or for all the related parameters

        gm identify -format "%[JPEG-*]" ~/seaworld.jpg
        JPEG-Quality=90
        JPEG-Colorspace=2
        JPEG-Colorspace-Name=RGB
        JPEG-Sampling-factors=2x2,1x1,1x1

        Great ! It is exactly what I was searching for. Better then modifying the whole code or parsing the output with regex.
        Can I only suggest to update the documentation, in order not to be bothered with the same question in the future ?
        Thanks a lot,
        regards

         

        Last edit: VdF 2015-03-10
  • Bob Friesenhahn

    Bob Friesenhahn - 2015-03-10

    I am doubtful that adding documentation will diminish questions but I have now added documentation for the JPEG-* -format tags.

     
  • Bob Friesenhahn

    Bob Friesenhahn - 2015-03-10
    • assigned_to: Glenn Randers-Pehrson --> Bob Friesenhahn
     
  • Bob Friesenhahn

    Bob Friesenhahn - 2015-03-10
    • status: open --> closed-fixed
     
  • Bob Friesenhahn

    Bob Friesenhahn - 2015-03-10

    Fixed by Mercurial changeset 14370:3060d10e408a.

     

Log in to post a comment.

MongoDB Logo MongoDB