locked
BitmapMetadata.SetQuery on png RRS feed

  • Question

  • Why can I only call one SetQuery on a PNG metadata? First one works, next one erases the previous query value.

    BitmapMetadata bm = new BitmapMetadata("png");
    bm.SetQuery("/Text/Description", "hello");
    bm.SetQuery("/Text/OlsCanZoom", "true");
    Debug.Assert(bm.ContainsQuery("/Text/OlsCanZoom")); // works
    Debug.Assert(bm.ContainsQuery("/Text/Description")); // fails - got lost somehow...
    bm.SetQuery("/Text/Description", "hello");
    Debug.Assert(bm.ContainsQuery("/Text/OlsCanZoom")); // fails

    This works on jpg or png:
    BitmapMetadata metadata = new BitmapMetadata("jpg");
    metadata.SetQuery("/app1/ifd/{uint=897}", "hello there");
    metadata.SetQuery("/app1/ifd/{uint=898}", "this is a test");
    Debug.Assert(metadata.ContainsQuery("/app1/ifd/{uint=897}"));
    Debug.Assert(metadata.ContainsQuery("/app1/ifd/{uint=898}"));

    Am I wrong in trying to use /Text/?

    ...Stefan
    Thursday, June 26, 2008 7:06 AM

Answers

  • In the first case (writing to /Text in PNG), each /Text is actually the same metadata block, which is identified by its keyword value. So first you wrote to the /Text block, and set its keyword value to "Description" and its text to "hello". Then you overwrote these values by writing "OlsCanZoom" to the keyworda and "true" to the text value. It's the same metadata block, so it just got overwritten.

     

    If you wish to write a second /Text block, then it would be referred to as /[1]Text. You can do this by creating a Text metadata writer and then calling bm.SetQuery("/", textWriter) to add each /Text block that you want.

     

    Monday, July 14, 2008 9:09 PM

All replies

  • In the first case (writing to /Text in PNG), each /Text is actually the same metadata block, which is identified by its keyword value. So first you wrote to the /Text block, and set its keyword value to "Description" and its text to "hello". Then you overwrote these values by writing "OlsCanZoom" to the keyworda and "true" to the text value. It's the same metadata block, so it just got overwritten.

     

    If you wish to write a second /Text block, then it would be referred to as /[1]Text. You can do this by creating a Text metadata writer and then calling bm.SetQuery("/", textWriter) to add each /Text block that you want.

     

    Monday, July 14, 2008 9:09 PM
  • I'm working on the same things right now and I'm a little confused about your solution. What is this text metadata writer? I've done a bunch of searching, but haven't found anything? Is this a class in the .NET framework? Or is this something we would have to implement ourselves?

    Tuesday, December 9, 2008 5:27 PM
  • "/text" is the "tEXT" metadata inside of a PNG.
    Tuesday, December 30, 2008 10:40 PM