예제 #1
0
        private string MakeKey(FileSystemInfo finfo)
        {
            var fname = finfo.Name.ToLowerInvariant();

            // Special case JPGs
            if (m_jpg_date_taken && Exif.IsJpgFile(finfo.FullName))
            {
                using (var fs = new FileStream(finfo.FullName, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    var exif = Exif.Read(fs, false);
                    if (exif != null && exif.HasTag(Exif.Tag.DateTimeOriginal))
                    {
                        var dat = exif[Exif.Tag.DateTimeOriginal];
                        var ts  = dat.AsString;
                        return(ts + "-" + fname);
                    }
                }
            }

            // Include the file size in the key
            if (finfo is FileInfo fi)
            {
                return(fi.Length + "-" + fname);
            }
            else
            {
                return(fname);
            }
        }
예제 #2
0
            /// <summary>Create a key for 'fi'</summary>
            public static string MakeKey(FileInfo fi)
            {
                // Generate a key for the file
                var fname = fi.Name.ToLowerInvariant();

                // Special case JPGs
                if (Exif.IsJpgFile(fi.FullName))
                {
                    using (var fs = new FileStream(fi.FullName, FileMode.Open, FileAccess.Read, FileShare.Read))
                    {
                        var exif = Exif.Read(fs, false);
                        if (exif != null && exif.HasTag(Exif.Tag.DateTimeOriginal))
                        {
                            var dat = exif[Exif.Tag.DateTimeOriginal];
                            var ts  = dat.AsString;
                            return(ts + "-" + fname);
                        }
                    }
                }

                // Include the file size in the key
                return(fi.Length + "-" + fname);
            }
예제 #3
0
        public override int Run()
        {
            try
            {
                if (!Exif.IsJpgFile(m_jpg_filepath))
                {
                    Console.WriteLine($" {m_jpg_filepath} - Not a valid JPG file");
                    return(1);
                }

                var exif = Exif.Load(m_jpg_filepath);
                foreach (var tag in exif.Tags)
                {
                    var field = exif[tag];
                    Console.WriteLine(field.ToString());
                }
                return(0);
            }
            catch (Exception ex)
            {
                Console.WriteLine($" Error: {ex.Message}");
                return(-1);
            }
        }