Atalasoft
Welcome to Atalasoft Community Sign in | Join | Help
in

Fastest way to detect an image's compression

Last post 19 Nov 2008, 10:47 AM by flipdoubt. 4 replies.
Sort Posts: Previous Next
  •  18 Nov 2008, 12:41 PM 16612

    Fastest way to detect an image's compression

    What is the fastest way to detect an image's compression? I use RegisteredDecoders.GetImageInfo for bit-depth, resolution, and related properties in ImageInfo, but I am not sure where to find compression.
    Filed under:
  •  19 Nov 2008, 7:47 AM 16620 in reply to 16612

    Re: Fastest way to detect an image's compression

    If you know what format it is, then the fastest way is to construct the right decoder and then call GetImageInfo() on the decoder, and then the decoder specific method for the compression.

    If you don't, then follow this procedure

    1. Call RegisteredDecoders.GetDecoder(stream) to get the decoder
    2. Call GetImageInfo on the decoder to get the bit-depth, etc (as before)
    3. Call the decoder specific methods for compression. For example, for a TIFF, you'll call tiffDecoder.GetTiffTag(TiffTagID.Compression, stream, frame) to find the compression used for the frame (each frame of a TIFF can have a different compression)

    For  step 3, you'll have to try to cast (with as) to different decoders to find out which function you need to call.  Let me know what formats you need more help on or look in the help for the specific decoder.

  •  19 Nov 2008, 9:09 AM 16625 in reply to 16620

    Re: Fastest way to detect an image's compression

    Wow. I was expecting a simple property somewhere, such as on the AtalaImage. I just want to get the compression for informational purposes.

    This might not be what you are asking for when you say "let me know what formats you need more help on", but we use three file formats: TIFF, PDF, and JPEG. It sounds like you are going to send me to each of the specific decoders. Does that mean there is no "decoder agnostic" way to ascertain the compression used on an image?
  •  19 Nov 2008, 10:11 AM 16626 in reply to 16625

    Re: Fastest way to detect an image's compression

    That is correct - there is no decoder agnostic way to determine compression.

    An image, as it stands, it totally detached from decoders - even though most image come from decoders, this is not necessarily the case.  An image could have come from whole cloth (constructed from scratch), cloned, or from the ImageResults object from an ImageCommand.  Compression makes no real sense in those cases.

    We are considering a tighter coupling between codecs and images in the future, but the compression question is still a little odd in that several image formats are clearing houses for many other compression types.  For example, a TIFF may contain images that are compressed with CCITT, LZW, and JPEG.  DICOM may contain images compressed with JPEG2000.  PDF may contain pages with (unlimited) multiple compressions per page.  On top of that, since the codec system in dotImage is totally open, there's no way to a priori specify all the compressions that you might see as end clients may extend and write their own codecs, so specifying compression as something logical like an enum doesn't work so well.

    The short answer is, it's tricky to get right - especially with PDF.


    Steve Hawley
    Architect & Exception Handler
    Atalasoft, Inc.
  •  19 Nov 2008, 10:47 AM 16627 in reply to 16626

    Re: Fastest way to detect an image's compression

    Thanks for the thoughtful explanation. I will post again if I run into issues.
View as RSS news feed in XML