Exemplo n.º 1
0
        public static DateTime? GetExifTakenAt(string path)
        {
            var takenAt = default(DateTime);
            using (var ei = new ExifInfo(path))
            {
                var dto = ei.GetPropertyString(ExifTagNames.ExifDTOrig);
                if (string.IsNullOrEmpty(dto))
                    return null;

                dto = string.Join(" ", dto.Split(' ').Select((val, idx) => idx == 0 ? val.Replace(":", "/") : val));
                if (!DateTime.TryParse(dto, out takenAt))
                    return null;
            }

            return takenAt;
        }
Exemplo n.º 2
0
        public static ExifOrientation GetExifOrientation(string path)
        {
            ExifOrientation orientation;
            using (var ei = new ExifInfo(path))
            {
                orientation = ei.Orientation;

                // メーカーと機種をチェックして補正する。
                var maker = ei.Maker.ToLower();

                // シャープの携帯はおかしい
                if (maker == "sharp")
                {
                    if (orientation == ExifOrientation.LeftSideBottom)
                        orientation = ExifOrientation.TopLeftSide;
                }
            }

            return orientation;
        }