Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - writing exif data

 
 
Old 11-29-2006   #1 (permalink)
Ralf Ziller


 
 

writing exif data

I am resizing a jpeg file and want to add some exif data.
But the data is not written. If I use windows explorer there is nothing in
the properties and if I read again via WPF there is nothing. If I set
properties with windows explorer I can read them with WPF.
Is there anything wrong with the code? How do I write exif data correctly?



BitmapImage biPreview = new BitmapImage();
biPreview.BeginInit();
biPreview.UriSource = new Uri(local0, UriKind.Absolute);
biPreview.DecodePixelHeight = h;
biPreview.DecodePixelWidth = w;
biPreview.EndInit();
BitmapMetadata bmmd = new BitmapMetadata("jpg");
bmmd.Title = title;

BitmapFrame bmFrame = BitmapFrame.Create(biPreview, null, bmmd, new
System.Collections.ObjectModel.ReadOnlyCollection<ColorContext>( col));
bmFrame = BitmapFrame.Create(biPreview);


JpegBitmapEncoder enc = new JpegBitmapEncoder();
enc.QualityLevel = 70;
enc.Frames.Add(bmFrame);
//write to filestream
enc.Save(fs);
fs.Close();



My System SpecsSystem Spec
Old 11-30-2006   #2 (permalink)
Ralf Ziller


 
 

Re: writing exif data


> BitmapMetadata bmmd = new BitmapMetadata("jpg");
> bmmd.Title = title;
>
> BitmapFrame bmFrame = BitmapFrame.Create(biPreview, null, bmmd, new
> System.Collections.ObjectModel.ReadOnlyCollection<ColorContext>( col));
> bmFrame = BitmapFrame.Create(biPreview);


This code is off course unbelievable stupid... the last line will discard
the metadata.
But if I get rid off this line I get a COMException (0xc0000005) on
enc.Save(fs);
If I use
bmmd.SetQuery("/app1/ifd/{uint=270}", title);
bmmd.SetQuery("/app1/ifd/exif/{uint=37510}", title);
and do not use
bmmd.Title = title;
the metadata gets saved (although not visible for Windows explorer, but I
can do without that).


My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
Displaying Exif Comments in Photo Gallery Vista music pictures video
Change EXIF and File dates PowerShell
Best way to set EXIF data in JPEGs PowerShell
Vista to search exif data? Vista General
Edit EXIF tags in Vista? Vista music pictures video


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46