Reading JPEG image compression type

V

Victory

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
 
M

mayayana

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.
 
G

Göran Andersson

Victory said:
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.
 
V

Victory

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
 
M

mayayana

http://www.media.mit.edu/pia/Research/deepview/exif.html

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 "PropertyItem" objects (or
properties?).
 
V

Victory

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.propertyItems. 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
 
M

mayayana

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.:
http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/EXIF.html

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top