tags:

views:

79

answers:

3

On some .JPG files (EPS previews, generated by Adobe Illustrator) in Windows 7 InPlaceBitmapMetadataWriter.TrySave() returns true after some SetQuery() calls, but does nothing.

Code sample:

BitmapDecoder decoder;
BitmapFrame frame;
BitmapMetadata metadata;
InPlaceBitmapMetadataWriter writer;
decoder = BitmapDecoder.Create(s, BitmapCreateOptions.PreservePixelFormat | BitmapCreateOptions.IgnoreColorProfile, BitmapCacheOption.Default);
frame = decoder.Frames[0];
metadata = frame.Metadata as BitmapMetadata;
writer = frame.CreateInPlaceBitmapMetadataWriter();
try {
    writer.SetQuery("System.Title", title);
    writer.SetQuery(@"/app1/ifd/{ushort=" + exiftagids[0] + "} ", (title + '\0').ToCharArray());
    writer.SetQuery(@"/app13/irb/8bimiptc/iptc/object name", title);
    return writer.TrySave();
}
catch {
    return false;
}

Image sample

You can reproduce problem (if you have Windows 7) by downloading image sample and using this code sample to set title on this image. Image has enough room for metadata - and this code sample works fine on my WinXP. Same code works fine on Win7 with other .JPG files.

Any ideas are welcome :)

A: 

I'm struggling with the same problem. Please, if anyone knows how to resolve this problem let us know!

tishon
Check my answer.
mephisto123
Which answer, mephisto123? If you mean the one above, have you posted a link to the wrapper somewhere? I would be really grateful if you share how you've worked around this problem.
tishon
A: 

I still didn't find the answer and has to write wrapper for exiftool instead of using WPF's way to work with metadata... May be som1 will find it useful.

mephisto123
+1  A: 
lazo
TrySave() returns _true_! But does nothing. So there is no way to find out if metadata is written or not.
mephisto123