Reading JPEG image compression type

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Victory

    Reading JPEG image compression type

    Hi,
    I need to know the compression type of jpeg (jpg) files. I am using the
    System.Drawing. Imaging and loading the file using an Image object. The
    next thing i do, is to examine the propertyItems property of the object
    which gives me an ID, a type and Value. I am able to check for an ID of
    259 (259 is the compression id) for Tiff images and check the value
    upper and lower significant bits of the value to see the compression.
    But i don't know how these (id, type, value) map for a jpeg image. Any
    ideas?
    thanks,
    Mars

    *** Sent via Developersdex http://www.developersdex.com ***
  • mayayana

    #2
    Re: Reading JPEG image compression type

    I don't know anything about your object wrapper,
    but if you parse a JPG header you find the tag 259
    (H103) in the IFD1 section used for the embedded
    thumbnail. A value of 1 means no compression. 6
    means JPG compression. I think there are also a
    couple of other rarely used compression types, but
    I'm not sure about that.
    I don't know of any Compression tag for the main
    image.
    I need to know the compression type of jpeg (jpg) files. I am using the
    System.Drawing. Imaging and loading the file using an Image object. The
    next thing i do, is to examine the propertyItems property of the object
    which gives me an ID, a type and Value. I am able to check for an ID of
    259 (259 is the compression id) for Tiff images and check the value
    upper and lower significant bits of the value to see the compression.
    But i don't know how these (id, type, value) map for a jpeg image. Any
    ideas?
    thanks,
    Mars
    >
    *** Sent via Developersdex http://www.developersdex.com ***

    Comment

    • =?ISO-8859-1?Q?G=F6ran_Andersson?=

      #3
      Re: Reading JPEG image compression type

      Victory wrote:
      Hi,
      I need to know the compression type of jpeg (jpg) files. I am using the
      System.Drawing. Imaging and loading the file using an Image object. The
      next thing i do, is to examine the propertyItems property of the object
      which gives me an ID, a type and Value. I am able to check for an ID of
      259 (259 is the compression id) for Tiff images and check the value
      upper and lower significant bits of the value to see the compression.
      But i don't know how these (id, type, value) map for a jpeg image. Any
      ideas?
      thanks,
      Mars
      >
      A Tiff file can use different compressions, like LZW or JPEG. A JPEG
      file only uses JPEG compression.

      --
      Göran Andersson
      _____
      Göran Anderssons privata hemsida.

      Comment

      • Victory

        #4
        Re: Reading JPEG image compression type

        Hi all,
        May be a little more explanation is needed here: When reading TIFF, then
        the propertyItems will have IDs defined based on the TIFF Standard
        definition. Based on the TIFF specs, when ID is 259, the values
        represent the type of compression. The compression values can be
        CCITTFAX3, CCITTFAX4, No Compression, and so on (the compression can
        even be JPG). However, i am reading a file with a JPG extension. This
        is different than a JPG within a TIFF.
        When reading a file with JPG extension, i need to know the IDs and
        structure defined so that i can appropriately map the data into the
        structure and find out the properties of the image. What i am interested
        in is the compression type. With JPG there are two main categories,
        Huffman and arithmetic encoding compression types. Please clarify if
        your answers i did not understand. This can be best answered by the
        Microsoft developer that wrote the Image object and all its classes.
        thank you,
        Mars

        *** Sent via Developersdex http://www.developersdex.com ***

        Comment

        • mayayana

          #5
          Re: Reading JPEG image compression type



          I don't know whether this will help, as you seem
          to be using a wrapper object with no direct access
          to the file header, and this link is for details about
          the JPG file header itself. If you look at that link you'll see
          that 259 is the EXIF tag number for Compression
          type of an embedded thumbnail. Your object apparently
          renders the tags as "PropertyIt em" objects (or
          properties?).




          Comment

          • Victory

            #6
            Re: Reading JPEG image compression type

            Mayayana,
            Thank you for the link, your inputs got me thinking and they were
            helpful,

            I am using the VB.NET's Image object in System.Drawing. ...
            So, i am not using a home brew wrapper. it is supposed to return the
            tags when i call image.propertyI tems. for a TIFF image, it returns all
            of them because the idea of a property in the image control closely
            resembles the one in the TIFF specification. However, with a JPG file,
            the same function returns only one ID which is 20624 or 0X5090 which
            corresponds to luminance. So, i figured i can't use the same method for
            both of these file formats. The TIFF docs use ID of 259 to refere to
            Compression just like in the JPEG documentation you sent me the link to.
            However, the function does not work the same for both types of images.
            This is perhaps due to the drastic difference that the two file formats
            have with each other.
            Mars

            *** Sent via Developersdex http://www.developersdex.com ***

            Comment

            • mayayana

              #7
              Re: Reading JPEG image compression type

              >
              I am using the VB.NET's Image object in System.Drawing. ...
              So, i am not using a home brew wrapper.
              Yes. I just meant a wrapper object in the sense that
              the .Net object is wrapping the file parsing, as opposed to
              reading the header directly. My only experience is in
              parsing the actual header. (Using VBScript and VB.
              I'm not familiar with that .Net object.)

              After I posted that other link I found another
              with more detailed info.:


              It looks like the info. at the first link was partial.
              Apparently the 259 tag can be used for both the
              image and the thumbnail, differentiated by whether
              the tag is in the IFD0 or IFD1 section.
              for a TIFF image, it returns all
              of them because the idea of a property in the image control closely
              resembles the one in the TIFF specification. However, with a JPG file,
              the same function returns only one ID which is 20624 or 0X5090 which
              corresponds to luminance. So, i figured i can't use the same method for
              both of these file formats. The TIFF docs use ID of 259 to refere to
              Compression just like in the JPEG documentation you sent me the link to.
              However, the function does not work the same for both types of images.
              Oh, well. I'm afraid I may have led you on a
              bit of a wild goose chase, at least as concerns
              the System.Drawing. Image object.


              Comment

              Working...