Esempio n. 1
0
        /// <summary>
        /// Creates an instance of the MetadataExtractor class.
        /// Reads metadata via WIC/WPF (.NET 3.0).
        /// If WIC lacks a metadata reader for this image type then fall back to .NET 2.0 method.
        /// </summary>
        /// <param name="frameWpf">Opened WPF image</param>
        public static MetadataExtractor FromBitmap(BitmapFrame frameWpf)
        {
            MetadataExtractor metadata = new MetadataExtractor();

            metadata.InitViaWpf(frameWpf);
            return(metadata);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates an instance of the MetadataExtractor class.
        /// Reads metadata via WIC/WPF (.NET 3.0).
        /// If WIC lacks a metadata reader for this image type then fall back to .NET 2.0 method.
        /// </summary>
        /// <param name="path">Filepath of image</param>
        /// <param name="useWic">true to use Windows Imaging Component; otherwise false.</param>
        public static MetadataExtractor FromFile(string path, bool useWic)
        {
            MetadataExtractor metadata = new MetadataExtractor();

#if USEWIC
            if (useWic)
            {
                metadata.InitViaWpf(path);
            }
            else
            {
                metadata.InitViaBmp(path);
            }
#else
            metadata.InitViaBmp(path);
#endif
            return(metadata);
        }
            /// <summary>
            /// Returns the details for the given item.
            /// </summary>
            /// <param name="key">Item key.</param>
            /// <param name="useWIC">true to use Windows Imaging Component; otherwise false.</param>
            /// <returns>An array of tuples containing item details or null if an error occurs.</returns>
            public override Utility.Tuple <ColumnType, string, object>[] GetDetails(object key, bool useWIC)
            {
                if (disposed)
                {
                    return(null);
                }

                string filename = (string)key;
                List <Utility.Tuple <ColumnType, string, object> > details = new List <Utility.Tuple <ColumnType, string, object> >();

                // Get file info
                if (File.Exists(filename))
                {
                    FileInfo info = new FileInfo(filename);
                    details.Add(new Utility.Tuple <ColumnType, string, object>(ColumnType.DateCreated, string.Empty, info.CreationTime));
                    details.Add(new Utility.Tuple <ColumnType, string, object>(ColumnType.DateAccessed, string.Empty, info.LastAccessTime));
                    details.Add(new Utility.Tuple <ColumnType, string, object>(ColumnType.DateModified, string.Empty, info.LastWriteTime));
                    details.Add(new Utility.Tuple <ColumnType, string, object>(ColumnType.FileSize, string.Empty, info.Length));
                    details.Add(new Utility.Tuple <ColumnType, string, object>(ColumnType.FilePath, string.Empty, info.DirectoryName ?? ""));
                    details.Add(new Utility.Tuple <ColumnType, string, object>(ColumnType.FolderName, string.Empty, info.Directory.Name ?? ""));

                    // Get metadata
                    MetadataExtractor metadata = MetadataExtractor.FromFile(filename, useWIC);
                    details.Add(new Utility.Tuple <ColumnType, string, object>(ColumnType.Dimensions, string.Empty, new Size(metadata.Width, metadata.Height)));
                    details.Add(new Utility.Tuple <ColumnType, string, object>(ColumnType.Resolution, string.Empty, new SizeF((float)metadata.DPIX, (float)metadata.DPIY)));
                    details.Add(new Utility.Tuple <ColumnType, string, object>(ColumnType.ImageDescription, string.Empty, metadata.ImageDescription ?? ""));
                    details.Add(new Utility.Tuple <ColumnType, string, object>(ColumnType.EquipmentModel, string.Empty, metadata.EquipmentModel ?? ""));
                    details.Add(new Utility.Tuple <ColumnType, string, object>(ColumnType.DateTaken, string.Empty, metadata.DateTaken));
                    details.Add(new Utility.Tuple <ColumnType, string, object>(ColumnType.Artist, string.Empty, metadata.Artist ?? ""));
                    details.Add(new Utility.Tuple <ColumnType, string, object>(ColumnType.Copyright, string.Empty, metadata.Copyright ?? ""));
                    details.Add(new Utility.Tuple <ColumnType, string, object>(ColumnType.ExposureTime, string.Empty, (float)metadata.ExposureTime));
                    details.Add(new Utility.Tuple <ColumnType, string, object>(ColumnType.FNumber, string.Empty, (float)metadata.FNumber));
                    details.Add(new Utility.Tuple <ColumnType, string, object>(ColumnType.ISOSpeed, string.Empty, (ushort)metadata.ISOSpeed));
                    details.Add(new Utility.Tuple <ColumnType, string, object>(ColumnType.UserComment, string.Empty, metadata.Comment ?? ""));
                    details.Add(new Utility.Tuple <ColumnType, string, object>(ColumnType.Rating, string.Empty, (ushort)metadata.Rating));
                    details.Add(new Utility.Tuple <ColumnType, string, object>(ColumnType.Software, string.Empty, metadata.Software ?? ""));
                    details.Add(new Utility.Tuple <ColumnType, string, object>(ColumnType.FocalLength, string.Empty, (float)metadata.FocalLength));
                }

                return(details.ToArray());
            }
Esempio n. 4
0
 /// <summary>
 /// Creates an instance of the MetadataExtractor class.
 /// Reads metadata via WIC/WPF (.NET 3.0).
 /// If WIC lacks a metadata reader for this image type then fall back to .NET 2.0 method.
 /// </summary>
 /// <param name="path">Filepath of image</param>
 public static MetadataExtractor FromFile(string path)
 {
     return(MetadataExtractor.FromFile(path, true));
 }