An Image can contain additional Information about the Camera or the Date it was taken. It’s quite easy to access those Information with C-Sharp. All you need to do is to add a Reference to PresentationCore
and WindowsBase
, include the System.Windows.Media.Imaging
Namespace and use the following Code-Snippet as a StartingPoint:
public DateTime GetDateTaken(string filePath) { using (FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read)) { BitmapFrame bitmapFrame = BitmapFrame.Create(fileStream, BitmapCreateOptions.DelayCreation, BitmapCacheOption.None); BitmapMetadata bitmapMetadata = bitmapFrame.Metadata as BitmapMetadata; return DateTime.Parse(bitmapMetadata.DateTaken); } }
#
Hi,
thanks for your code. how to write metadata into an image?
#
@wp themes
There are many posts which can help you out. Just search for the Keyword “BitmapMetadata”. There’s one here which may help you:
http://blog.andreweichacker.com/2009/02/reading-and-writing-tags-for-photos-in-wpf/