BitmapDecoder Metadata via HTTP URI

I am trying to read MetaData (i.e. Camera used in a photo) from an image sitting on my website. I know the metadata is in the photo, and I know the web server is transferring it by watching a HexDump of the data after a direct request to the server. Also, when I transfer the photo to my local harddrive, I can read the MetaData with the following code:

Uri uri = new Uri("file://c:\\temp\\testimage.jpg");
BitmapDecoder decoder = BitmapDecoder.Create(uri, BitmapCreateOptions.None, BitmapCacheOption.None);
BitmapFrame frame = decoder.Frames[0];
BitmapMetadata m = frame.Metadata as BitmapMetadata;

However, whenever I change the uri to use an HTTP style and pull the image directly from my website without saving it to disk first, the _safehandle Non-Public Member of the BitmapDecoder class goes to Null, and the Metadata property of that same class shows an error message of "SafeHandle cannot be null".

Is there anyway to have the BitmapDecoder class consider an HTTP image request to be a SafeHandle so it will parse the MetaData from the image

Thx.

}Dan



Answer this question

BitmapDecoder Metadata via HTTP URI

  • RAFIKABDAT

    Interesting. This seems like a product bug then. I'll make sure that this is reported appropriately.
  • Karlo

    No problem. I'll look for my "I found a WPF bug for Microsoft, and all I got was this shirt." T-Shirt in the mail.

    :-)


  • Wayne.C

    After typing my previous message, I got to looking at my code, and I am trying to get the metadata from the first frame.

    BitmapFrame frame = decoder.Frames[0];
    BitmapMetadata m = frame.Metadata as BitmapMetadata;

    So I tried to get it off the "top level" as an option you suggested, but unfortunately that has failed as well with the same safehandle being null issue.


  • guaro

    Actually, can you try one more thing... Can you try getting the metadata off the first frame on the decoder Most decoders don't support "top level" metadata", but rather the metadata is on the individual frames.
  • sl333

    Can you try with BitmapCacheOption.Onload
  • Jeff Patton

    Ok. I'll report this bug then.

    Thanks for finding this!


  • Christopher Lusardi

    Attempted with BitmapCacheOptions.Onload with the exact same results.  No change.
  • wazimu

    If that was the case, why would that differ between retrieving metadata from the image sitting on a local harddrive to an image coming from a web site Since it is the exact same image, utilizing the same decoder, just differing in the medium of file retrieval, I would think you would run into the same problem, which in my test scenario described above, I am not.
  • BitmapDecoder Metadata via HTTP URI