Exemplo n.º 1
0
        public FileExtendedInfo(FileInfo fileInfo, string fileKey, PictureExifInformation exifInfoInfo, DateTime detectedTime)
        {
            Name                 = fileInfo.Name.RemoveDiacritics();
            ParentFolder         = fileInfo?.Directory?.Name;
            Creation             = fileInfo.CreationTimeUtc;
            FileKey              = fileKey;
            LastWriteDateTimeUtc = fileInfo.LastWriteTimeUtc;
            ContentChanged       = true;
            FilePath             = fileInfo.FullName;
            RelativePath         = MakeRelativePath(TripLineConfig.PictureFolderPath, fileInfo.Directory.FullName);

            LastAccessTimeUtc = fileInfo.LastAccessTimeUtc;
            LastWriteTime     = fileInfo.LastWriteTime;
            DetectedTime      = detectedTime;

            ExifInfo = exifInfoInfo;
        }
Exemplo n.º 2
0
        public PictureExifInformation GetExifInformation(string filepath)
        {
            var inf = new PictureExifInformation();

            try
            {
                using (ExifReader reader = new ExifReader(filepath))
                {
                    // Extract the tag data using the ExifTags enumeration
                    InfoMessages.Clear();

                    InfoMessages.Add($"Info from picture {filepath}");
                    bool notFound;

                    inf.DateTime = Get <DateTime>(reader, ExifTags.DateTime, ExifTags.DateTimeDigitized, out notFound);
                    if (notFound)
                    {
                        inf.DateTime = null;
                    }

                    inf.GPS_Latitude = Get24BitPosition(reader, ExifTags.GPSLatitude, ExifTags.GPSDestLatitude,
                                                        out notFound);
                    if (notFound)
                    {
                        inf.GPS_Latitude = null;
                    }

                    inf.GPS_Longitude = Get24BitPosition(reader, ExifTags.GPSLongitude, ExifTags.GPSDestLongitude,
                                                         out notFound);
                    if (notFound)
                    {
                        inf.GPS_Longitude = null;
                    }

                    inf.LatitudeRef = Get <string>(reader, ExifTags.GPSLatitudeRef, out notFound);
                    if (notFound)
                    {
                        inf.LatitudeRef = "N";
                    }

                    inf.LongitudeRef = Get <string>(reader, ExifTags.GPSLongitudeRef, out notFound);
                    if (notFound)
                    {
                        inf.LongitudeRef = "W";
                    }


                    if (inf.GPS_Latitude != null)
                    {
                        inf.GPS_Latitude = FixLatitude(inf.LatitudeRef, inf.GPS_Latitude.Value);
                    }

                    if (inf.GPS_Longitude != null)
                    {
                        inf.GPS_Longitude = FixLongitude(inf.LongitudeRef, inf.GPS_Longitude.Value);
                    }
                }
            }
            catch (Exception ex)
            {
                InfoMessages.Add($"Exception while GetExifInformation {filepath} {ex.Message}");
            }


            return(inf);
        }