Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jul 20, 2009 03:37 AM by Nai-Dong Jin - MSFT
Participant
786 Points
226 Posts
Jul 14, 2009 01:13 AM|LINK
I'm trying to add some exif info to a png, but I can't seem to find documentation on how to accomplish this.
Is there anything in the framework? Or a good document online explaining how one would go about this?
Thanks
-c
png Exif
Jul 14, 2009 01:54 AM|LINK
This is what I have so far, but it doesn't seem to actually save.
if (File.Exists(pngPath)) { using (Stream pngStream = File.Open(pngPath, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite)) { PngBitmapDecoder pngDecoder = new PngBitmapDecoder(pngStream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.OnLoad); BitmapFrame pngFrame = pngDecoder.Frames[0]; InPlaceBitmapMetadataWriter pngInplace = pngFrame.CreateInPlaceBitmapMetadataWriter(); if (pngInplace.TrySave() == true) { pngInplace.SetQuery("/Text/Description", "Testing"); } pngStream.Close(); } }
All-Star
41630 Points
3558 Posts
Jul 20, 2009 03:37 AM|LINK
Hi,
You may try the following code, change BitmapCacheOption.OnLoad to BitmapCacheOption.Default.
Stream pngStream = new System.IO.FileStream("winter.png", FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite); PngBitmapDecoder pngDecoder = new PngBitmapDecoder(pngStream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default); BitmapFrame pngFrame = pngDecoder.Frames[0]; InPlaceBitmapMetadataWriter pngInplace = pngFrame.CreateInPlaceBitmapMetadataWriter(); if (pngInplace.TrySave() == true) { pngInplace.SetQuery("/Text/Author", "Me"); } pngStream.Close();
Thanks.
gibble
Participant
786 Points
226 Posts
Add/Modify EXIF info of PNG file
Jul 14, 2009 01:13 AM|LINK
I'm trying to add some exif info to a png, but I can't seem to find documentation on how to accomplish this.
Is there anything in the framework? Or a good document online explaining how one would go about this?
Thanks
-c
png Exif
gibble
Participant
786 Points
226 Posts
Re: Add/Modify EXIF info of PNG file
Jul 14, 2009 01:54 AM|LINK
This is what I have so far, but it doesn't seem to actually save.
if (File.Exists(pngPath)) { using (Stream pngStream = File.Open(pngPath, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite)) { PngBitmapDecoder pngDecoder = new PngBitmapDecoder(pngStream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.OnLoad); BitmapFrame pngFrame = pngDecoder.Frames[0]; InPlaceBitmapMetadataWriter pngInplace = pngFrame.CreateInPlaceBitmapMetadataWriter(); if (pngInplace.TrySave() == true) { pngInplace.SetQuery("/Text/Description", "Testing"); } pngStream.Close(); } }Nai-Dong Jin...
All-Star
41630 Points
3558 Posts
Re: Add/Modify EXIF info of PNG file
Jul 20, 2009 03:37 AM|LINK
Hi,
You may try the following code, change BitmapCacheOption.OnLoad to BitmapCacheOption.Default.
Stream pngStream = new System.IO.FileStream("winter.png", FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite); PngBitmapDecoder pngDecoder = new PngBitmapDecoder(pngStream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default); BitmapFrame pngFrame = pngDecoder.Frames[0]; InPlaceBitmapMetadataWriter pngInplace = pngFrame.CreateInPlaceBitmapMetadataWriter(); if (pngInplace.TrySave() == true) { pngInplace.SetQuery("/Text/Author", "Me"); } pngStream.Close();Thanks.