/// <summary> /// Write Metadata to the Jpeg file, with no expection handling /// </summary> private void UnhandledWriteMetadata() { List <CompareResult> changes = new List <CompareResult>(); // Compare the two PhotoMetadataTools.CompareMetadata(this.InternalPhotoMetadataInFile, this.InternalPhotoMetadata, ref changes); // Save if there have been changes to the Metadata if (changes.Count > 0) { // Set the Last Edit Date this.Metadata.FotoflyDateLastSave = DateTime.Now; this.Metadata.CreationSoftware = FotoflyAssemblyInfo.ShortBuildVersion; // Read the file using (WpfFileManager wpfFileManager = new WpfFileManager(this.FileFullName, true)) { // Copy values across PhotoMetadataTools.WriteBitmapMetadata(wpfFileManager.BitmapMetadata, this.InternalPhotoMetadata); // Save file wpfFileManager.WriteMetadata(); // Save new BitmapMetadata as MetadataInFile this.InternalPhotoMetadataInFile = PhotoMetadataTools.ReadBitmapMetadata(wpfFileManager.BitmapMetadata); } } }
public static void WriteBitmapMetadata(BitmapMetadata bitmapMetadata, PhotoMetadata photoMetadata) { FileMetadata fileMetadata = new FileMetadata(bitmapMetadata); // List of changes, used for debugging List <CompareResult> compareResults = new List <CompareResult>(); // Use Reflection to Copy all values from photoMetadata to FileMetadata PhotoMetadataTools.UseReflection(photoMetadata, fileMetadata, true, ref compareResults); }
/// <summary> /// Writes the Metadata to an Xml file /// </summary> /// <param name="fileName">Filename of xml output</param> public void WriteMetadataToXml(string fileName) { if (this.Metadata == null) { throw new Exception("Metadata can not be read"); } else { PhotoMetadataTools.WritePhotoMetadataToXml(this.Metadata, fileName); } }
/// <summary> /// Reads the Jpeg Metadata from an Xml file /// </summary> /// <param name="fileName"></param> public void ReadMetadataFromXml(string fileName) { this.SetFileName(fileName); if (!File.Exists(this.FileFullName)) { throw new Exception("File does not exist: " + this.FileFullName); } this.InternalPhotoMetadata = PhotoMetadataTools.ReadPhotoMetadataFromXml(fileName); this.InternalPhotoMetadataInFile = PhotoMetadataTools.ReadPhotoMetadataFromXml(fileName); }
public static PhotoMetadata ReadBitmapMetadata(BitmapMetadata bitmapMetadata, BitmapDecoder bitmapDecoder) { PhotoMetadata photoMetadata = new PhotoMetadata(); // Load Metadata Reader FileMetadata fileMetadata = new FileMetadata(bitmapMetadata); // List of changes, used for debugging List <CompareResult> compareResults = new List <CompareResult>(); PhotoMetadataTools.UseReflection(fileMetadata, photoMetadata, true, ref compareResults); // Use Reflection to Copy all values from fileMetadata to photoMetadata return(photoMetadata); }
/// <summary> /// Compares the Metadata with the metadata stored in the original file /// </summary> /// <returns>A list of changes</returns> public List <CompareResult> CompareMetadataToFileMetadata() { if (!this.IsFileNameValid) { throw new Exception("File does not exist or is not valid: " + this.FileFullName); } List <CompareResult> compareResults = new List <CompareResult>(); // Compare the two PhotoMetadataTools.CompareMetadata(this.MetadataInFile, this.Metadata, ref compareResults); // Sort var query = from x in compareResults orderby x select x; return(query.ToList()); }
/// <summary> /// Read Metadata from the Jpeg file, with no expection handling /// </summary> private void UnhandledReadMetadata() { this.InternalPhotoMetadata = new PhotoMetadata(); this.InternalPhotoMetadataInFile = new PhotoMetadata(); // Read BitmapMetadata using (WpfFileManager wpfFileManager = new WpfFileManager(this.FileFullName)) { // Copy that gets changed this.InternalPhotoMetadata = PhotoMetadataTools.ReadBitmapMetadata(wpfFileManager.BitmapMetadata, wpfFileManager.BitmapDecoder); this.InternalPhotoMetadata.ImageHeight = wpfFileManager.BitmapDecoder.Frames[0].PixelHeight; this.InternalPhotoMetadata.ImageWidth = wpfFileManager.BitmapDecoder.Frames[0].PixelWidth; // Copy saved metadata for comparisons this.InternalPhotoMetadataInFile = PhotoMetadataTools.ReadBitmapMetadata(wpfFileManager.BitmapMetadata, wpfFileManager.BitmapDecoder); this.InternalPhotoMetadataInFile.ImageHeight = wpfFileManager.BitmapDecoder.Frames[0].PixelHeight; this.InternalPhotoMetadataInFile.ImageWidth = wpfFileManager.BitmapDecoder.Frames[0].PixelWidth; } }
public static void CompareMetadata(object source, object destination, ref List <CompareResult> changes) { PhotoMetadataTools.UseReflection(source, destination, false, ref changes); }
public static PhotoMetadata ReadBitmapMetadata(BitmapMetadata bitmapMetadata) { return(PhotoMetadataTools.ReadBitmapMetadata(bitmapMetadata, null)); }