On some .JPG files (EPS previews, generated by Adobe Illustrator) in Windows 7 InPlaceBitmapMetadataWriter.TrySave() returns true after some SetQuery() calls, but does nothi
Two things:
I don't think you will be able to write to your metadata
variable just like that, as it will be Frozen. So, you will have to clone it:
BitmapMetadata metadata = frame.Metadata.Clone() as BitmapMetadata;
Padding, you need padding. I found this out after about a day's worth of tinkering around trying to make some code (similar to yours) work. InPlaceBitmapMetadataWriter
will not work if there is no metadata padding in your image file. So you need something like:
JpegBitmapEncoder encoder = new JpegBitmapEncoder(); if(frame != null && metadata != null) { metadata.SetQuery("/app1/ifd/PaddingSchema:Padding", padding); encoder.Frames.Add(BitmapFrame.Create(frame, frame.Thumbnail, metadata, frame.ColorContexts)); using (Stream outputFile = File.Open(_myoutputpath, FileMode.Create, FileAccess.ReadWrite)) { encoder.Save(outputFile); } }
Now you can use the file located at _myoutputpath
which has added metadata padding for your InPlaceBitmapMetadataWriter
operations.
This article and attached code should help you out.