/// <summary> /// Constructs and initializes a new instance of <see /// cref="File" /> for a specified file abstraction and /// specified read style. /// </summary> /// <param name="abstraction"> /// A <see cref="File.IFileAbstraction" /> object to use when /// reading from and writing to the file. /// </param> /// <param name="propertiesStyle"> /// A <see cref="ReadStyle" /> value specifying at what level /// of accuracy to read the media properties, or <see /// cref="ReadStyle.None" /> to ignore the properties. /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="abstraction" /> is <see langword="null" /// />. /// </exception> public File(File.IFileAbstraction abstraction, ReadStyle propertiesStyle) : base(abstraction) { ImageTag = new CombinedImageTag(TagTypes.TiffIFD | TagTypes.XMP); Mode = AccessMode.Read; try { Read(propertiesStyle); TagTypesOnDisk = TagTypes; } finally { Mode = AccessMode.Closed; } }
/// <summary> /// Reads the information from file with a specified read style. /// </summary> /// <param name="propertiesStyle"> /// A <see cref="ReadStyle" /> value specifying at what level /// of accuracy to read the media properties, or <see /// cref="ReadStyle.None" /> to ignore the properties. /// </param> void Read (ReadStyle propertiesStyle) { Mode = AccessMode.Read; try { ImageTag = new CombinedImageTag (TagTypes.TiffIFD); ReadFile (); TagTypesOnDisk = TagTypes; if ((propertiesStyle & ReadStyle.Average) != 0) properties = ExtractProperties (); } finally { Mode = AccessMode.Closed; } }
/// <summary> /// Reads the information from file with a specified read style. /// </summary> /// <param name="propertiesStyle"> /// A <see cref="ReadStyle" /> value specifying at what level /// of accuracy to read the media properties, or <see /// cref="ReadStyle.None" /> to ignore the properties. /// </param> private void Read(ReadStyle propertiesStyle) { Mode = AccessMode.Read; try { ImageTag = new CombinedImageTag(TagTypes.TiffIFD); ReadFile(); TagTypesOnDisk = TagTypes; if (propertiesStyle != ReadStyle.None) { properties = ExtractProperties(); } } finally { Mode = AccessMode.Closed; } }
/// <summary> /// Reads the information from file with a specified read style. /// </summary> /// <param name="propertiesStyle"> /// A <see cref="ReadStyle" /> value specifying at what level /// of accuracy to read the media properties, or <see /// cref="ReadStyle.None" /> to ignore the properties. /// </param> void Read(ReadStyle propertiesStyle) { Mode = AccessMode.Read; try { ImageTag = new CombinedImageTag(TagTypes.XMP | TagTypes.Png); ValidateHeader(); ReadMetadata(); TagTypesOnDisk = TagTypes; if ((propertiesStyle & ReadStyle.Average) != 0) { properties = ExtractProperties(); } } finally { Mode = AccessMode.Closed; } }
/// <summary> /// Reads the information from file with a specified read style. /// </summary> /// <param name="propertiesStyle"> /// A <see cref="ReadStyle" /> value specifying at what level /// of accuracy to read the media properties, or <see /// cref="ReadStyle.None" /> to ignore the properties. /// </param> private void Read(ReadStyle propertiesStyle) { Mode = AccessMode.Read; try { ImageTag = new CombinedImageTag(TagTypes.XMP | TagTypes.TiffIFD | TagTypes.JpegComment | TagTypes.IPTCIIM); ValidateHeader(); ReadMetadata(); TagTypesOnDisk = TagTypes; if (propertiesStyle != ReadStyle.None) { properties = ExtractProperties(); } } finally { Mode = AccessMode.Closed; } }
public ToxyMetadata Parse() { if (!System.IO.File.Exists(Context.Path)) { throw new System.IO.FileNotFoundException("File " + Context.Path + " is not found"); } ToxyMetadata metadatas = new ToxyMetadata(); TagLib.File file = TagLib.Image.File.Create(Context.Path); if (file.Properties.PhotoHeight != 0) { metadatas.Add("PhotoHeight", file.Properties.PhotoHeight); } if (file.Properties.PhotoQuality != 0) { metadatas.Add("PhotoQuality", file.Properties.PhotoQuality); } if (file.Properties.PhotoWidth != 0) { metadatas.Add("PhotoWidth", file.Properties.PhotoWidth); } CombinedImageTag tags = file.Tag as CombinedImageTag; if (tags.Altitude != null) { metadatas.Add("Altitude", (double)tags.Altitude); } if (tags.Latitude != null) { metadatas.Add("Latitude", (double)tags.Latitude); } if (tags.Model != null) { metadatas.Add("Model", tags.Model); } if (tags.Make != null) { metadatas.Add("Make", tags.Make); } if (tags.Orientation != ImageOrientation.None) { metadatas.Add("Make", tags.Orientation); } if (tags.Longitude != null) { metadatas.Add("Longitude", (double)tags.Longitude); } if (tags.Keywords.Length > 0) { metadatas.Add("Keywords", string.Join(",", tags.Keywords)); } if (tags.ISOSpeedRatings != null) { metadatas.Add("ISOSpeedRatings", (uint)tags.ISOSpeedRatings); } if (tags.Creator != null) { metadatas.Add("Creator", tags.Creator); } if (!string.IsNullOrEmpty(tags.Comment)) { metadatas.Add("Comment", tags.Comment); } if (!string.IsNullOrEmpty(tags.Description)) { metadatas.Add("Comment", tags.Description); // TODO: sort this out } if (tags.Rating != null) { metadatas.Add("Rating", (uint)tags.Rating); } if (tags.Software != null) { metadatas.Add("Software", tags.Software); } if (tags.FNumber != null) { metadatas.Add("FNumber", (double)tags.FNumber); } if (tags.ExposureTime != null) { metadatas.Add("ExposureTime", (double)tags.ExposureTime); } if (tags.FocalLength != null) { metadatas.Add("FocalLength", (double)tags.FocalLength); } if (tags.FocalLengthIn35mmFilm != null) { metadatas.Add("FocalLengthIn35mmFilm", (uint)tags.FocalLengthIn35mmFilm); } if (tags.DateTime != null) { metadatas.Add("DateTime", (DateTime)tags.DateTime); } if ((file.TagTypes & TagLib.TagTypes.XMP) == TagLib.TagTypes.XMP) { TagLib.Xmp.XmpTag tagXmp = file.GetTag(TagLib.TagTypes.XMP) as TagLib.Xmp.XmpTag; foreach (TagLib.Xmp.XmpNode node in tagXmp.NodeTree.Children) { if (!string.IsNullOrEmpty(node.Value)) { metadatas.Add(node.Name, node.Value); } } } if ((file.TagTypes & TagLib.TagTypes.GifComment) == TagLib.TagTypes.GifComment) { TagLib.Gif.GifCommentTag tagGif = file.GetTag(TagLib.TagTypes.GifComment) as TagLib.Gif.GifCommentTag; metadatas.Add("GifComment", tagGif.Comment); } return(metadatas); }
/// <summary> /// Constructs and initializes a new instance of <see /// cref="File" /> for a specified file abstraction and /// specified read style. /// </summary> /// <param name="abstraction"> /// A <see cref="File.IFileAbstraction" /> object to use when /// reading from and writing to the file. /// </param> /// <param name="propertiesStyle"> /// A <see cref="ReadStyle" /> value specifying at what level /// of accuracy to read the media properties, or <see /// cref="ReadStyle.None" /> to ignore the properties. /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="abstraction" /> is <see langword="null" /// />. /// </exception> public File(File.IFileAbstraction abstraction, ReadStyle propertiesStyle) : base(abstraction) { ImageTag = new CombinedImageTag(TagTypes.XMP); }
/// <summary> /// Constructs and initializes a new instance of <see /// cref="File" /> for a specified file abstraction and /// specified read style. /// </summary> /// <param name="abstraction"> /// A <see cref="IFileAbstraction" /> object to use when /// reading from and writing to the file. /// </param> /// <param name="propertiesStyle"> /// A <see cref="ReadStyle" /> value specifying at what level /// of accuracy to read the media properties, or <see /// cref="ReadStyle.None" /> to ignore the properties. /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="abstraction" /> is <see langword="null" /// />. /// </exception> public File(File.IFileAbstraction abstraction, ReadStyle propertiesStyle) : base(abstraction) { ImageTag = new CombinedImageTag (TagTypes.XMP); }