示例#1
0
        /// <summary>
        /// Removes GPS data and updates the image files in a directory
        /// </summary>
        public void RemoveExifLocation()
        {
            // Map directory in source folder
            string sourceDirectoryPath = Common.MapSourceFilePath(this.CleanerPath);

            // get array of file in specific directory
            string[] files = Directory.GetFiles(sourceDirectoryPath);

            foreach (string path in files)
            {
                // get EXIF data if exists
                ExifMetadata exifMetadata = (ExifMetadata)MetadataUtility.ExtractSpecificMetadata(path, MetadataType.EXIF);

                if (exifMetadata != null)
                {
                    ExifInfo exifInfo = exifMetadata.Data;

                    if (exifInfo.GPSData != null)
                    {
                        // set altitude, latitude and longitude to null values
                        exifInfo.GPSData.Altitude     = null;
                        exifInfo.GPSData.Latitude     = null;
                        exifInfo.GPSData.LatitudeRef  = null;
                        exifInfo.GPSData.Longitude    = null;
                        exifInfo.GPSData.LongitudeRef = null;
                    }

                    // and update file
                    MetadataUtility.UpdateMetadata(path, exifMetadata);
                }
            }
            Console.WriteLine("Press any key to exit.");
        }
示例#2
0
        private static string Create(string path)
        {
            string name = ExifInfo.Get(path);

            if (name != null)
            {
                return(Path.Combine(Path.GetDirectoryName(path), MakeGoodName(name + Path.GetExtension(path))));
            }
            else
            {
                return(Path.Combine(Path.GetDirectoryName(path), ("No_date" + Path.GetExtension(path))));
            }
        }
示例#3
0
        private static string Create(string path, int counter)
        {
            string name = ExifInfo.Get(path);

            if (name != null)
            {
                return(Path.Combine(Path.GetDirectoryName(path), MakeGoodName(name + " (" + counter.ToString() + ")" + Path.GetExtension(path))));
            }
            else
            {
                return(Path.Combine(Path.GetDirectoryName(path), ("No_date" + "_(" + counter.ToString() + ")" + Path.GetExtension(path))));
            }
        }
示例#4
0
        public PropertyItem[] GetExifValues(short id)
        {
            ExifInfo info = (ExifInfo)this.exifIdToExifInfo[id];

            if (info == null)
            {
                return(new PropertyItem[0]);
            }
            else
            {
                return((PropertyItem[])info.items.Clone());
            }
        }
示例#5
0
        public void RemoveExifValues(short id)
        {
            object   idObj = (object)id;
            ExifInfo info  = (ExifInfo)this.exifIdToExifInfo[idObj];

            OnChanging();
            ++suppressChangeEvents;

            if (info != null)
            {
                foreach (string name in info.names)
                {
                    RemoveValue(ExifSectionName, name);
                }

                this.exifIdToExifInfo.Remove(idObj);
            }

            --suppressChangeEvents;
            OnChanged();
        }
示例#6
0
        /// <summary>
        /// Reads as exif information.
        /// </summary>
        /// <returns>ExifInfo.</returns>
        public ExifInfo ReadAsExifInfo()
        {
            var result = new ExifInfo
            {
                Width                = this._image.Width,
                Height               = this._image.Height,
                ResolutionX          = this.ResolutionX,
                ResolutionY          = this.ResolutionY,
                Orientation          = this.Orientation,
                Title                = this.Title,
                Description          = this.Description,
                Copyright            = this.Copyright,
                LastUpdatedStamp     = this.LastUpdatedStamp,
                DigitizedStamp       = this.DigitizedStamp,
                OriginalStamp        = this.OriginalStamp,
                Software             = this.Software,
                EquipmentMaker       = this.EquipmentMaker,
                EquipmentModel       = this.EquipmentModel,
                ExposureTime         = this.ExposureTime,
                ExposureProgram      = this.ExposureProgram,
                Artist               = this.Artist,
                UserComment          = this.UserComment,
                LightSource          = this.LightSource,
                FlashMode            = this.FlashMode,
                ExposureMeteringMode = this.ExposureMeteringMode,
                Aperture             = this.Aperture,
                ISO             = this.ISO,
                SubjectDistance = this.SubjectDistance,
                FocalLength     = this.FocalLength,
                GeoPosition     = (this.Latitude.HasValue && this.Longitude.HasValue) ? new GeoPosition
                {
                    Latitude  = this.Latitude.Value,
                    Longitude = this.Longitude.Value
                } as GeoPosition? : null
            };

            return(result);
        }
        //ExEnd:ApplyLicense
        public static string CleanFile(string filePath)
        {
            try
            {
                try
                {
                    //Apply license...
                    ApplyLicense();
                }
                catch (Exception exp)
                {
                    MessageBox.Show("In Licence: " + exp.Message);
                }
                try
                {
                    //Recognize format of file...
                    FormatBase format = FormatFactory.RecognizeFormat(filePath);

                    if (format.Type.ToString().ToLower() == "doc" || format.Type.ToString().ToLower() == "docx")
                    {
                        // initialize DocFormat...
                        DocFormat docFormat = format as DocFormat;
                        if (docFormat != null)
                        {
                            // get document properties...
                            DocMetadata properties = new DocMetadata();
                            properties = docFormat.DocumentProperties;

                            //Remove custom properties...
                            foreach (KeyValuePair <string, PropertyValue> keyValuePair in properties)
                            {
                                if (!properties.IsBuiltIn(keyValuePair.Key))
                                {
                                    properties.Remove(keyValuePair.Key);
                                }
                            }

                            //Reset built-in properties...
                            properties.Author        = "";
                            properties.Category      = "";
                            properties.Comments      = "";
                            properties.Company       = "";
                            properties.ContentStatus = "";
                            properties.HyperlinkBase = "";
                            properties.Keywords      = "";
                            properties.Manager       = "";
                            properties.Title         = "";

                            //Update metadata if file...
                            MetadataUtility.UpdateMetadata(filePath, properties);
                        }
                        return("1");
                    }
                    else if (format.Type.ToString().ToLower() == "xls" || format.Type.ToString().ToLower() == "xlsx")
                    {
                        //Initialize XlsFormat...
                        XlsFormat xlsFormat = format as XlsFormat;
                        if (xlsFormat != null)
                        {
                            //Get document properties...
                            XlsMetadata properties = xlsFormat.DocumentProperties;

                            //Remove custom properties...
                            foreach (KeyValuePair <string, PropertyValue> keyValuePair in properties)
                            {
                                if (!properties.IsBuiltIn(keyValuePair.Key))
                                {
                                    properties.Remove(keyValuePair.Key);
                                }
                            }

                            //Reset built-in properties...
                            properties.Author        = "";
                            properties.Category      = "";
                            properties.Comments      = "";
                            properties.Company       = "";
                            properties.HyperlinkBase = "";
                            properties.Keywords      = "";
                            properties.Manager       = "";
                            properties.Title         = "";
                            properties.Subject       = "";

                            //Update metadata in files...
                            MetadataUtility.UpdateMetadata(filePath, properties);
                        }
                        return("1");
                    }
                    else if (format.Type.ToString().ToLower() == "ppt" || format.Type.ToString().ToLower() == "pptx")
                    {
                        //Initialize PptFormat...
                        PptFormat pptFormat = format as PptFormat;
                        if (pptFormat != null)
                        {
                            //Get document properties...
                            PptMetadata properties = pptFormat.DocumentProperties;

                            //Remove custom properties
                            foreach (KeyValuePair <string, PropertyValue> keyValuePair in properties)
                            {
                                if (!properties.IsBuiltIn(keyValuePair.Key))
                                {
                                    properties.Remove(keyValuePair.Key);
                                }
                            }

                            //Reset built-in properties...
                            properties.Author   = "";
                            properties.Category = "";
                            properties.Comments = "";
                            properties.Company  = "";
                            properties.Keywords = "";
                            properties.Manager  = "";
                            properties.Title    = "";
                            properties.Subject  = "";

                            //Update metadata of file...
                            MetadataUtility.UpdateMetadata(filePath, properties);
                        }
                        return("1");
                    }
                    else if (format.Type.ToString().ToLower() == "pdf")
                    {
                        // initialize PdfFormat...
                        PdfFormat pdfFormat = format as PdfFormat;
                        if (pdfFormat != null)
                        {
                            // get document properties...
                            PdfMetadata properties = pdfFormat.DocumentProperties;

                            // Remove custom properties...
                            foreach (KeyValuePair <string, PropertyValue> keyValuePair in properties)
                            {
                                if (!properties.IsBuiltIn(keyValuePair.Key))
                                {
                                    properties.Remove(keyValuePair.Key);
                                }
                            }

                            //Reset built-in properties...
                            properties.Author       = "";
                            properties.CreatedDate  = DateTime.MinValue;
                            properties.Keywords     = "";
                            properties.ModifiedDate = DateTime.MinValue;
                            properties.Subject      = "";
                            properties.TrappedFlag  = false;
                            properties.Title        = "";

                            //Update metadata of file...
                            MetadataUtility.UpdateMetadata(filePath, properties);
                        }
                        return("1");
                    }
                    else if (format.Type.ToString().ToLower() == "jpeg" || format.Type.ToString().ToLower() == "jpg")
                    {
                        //Get EXIF data if exists
                        ExifMetadata exifMetadata = (ExifMetadata)MetadataUtility.ExtractSpecificMetadata(filePath, MetadataType.EXIF);

                        //Get XMP data if exists
                        XmpMetadata xmpMetadata = (XmpMetadata)MetadataUtility.ExtractSpecificMetadata(filePath, MetadataType.XMP);
                        if (exifMetadata != null)
                        {
                            //Remove exif info...
                            ExifInfo exifInfo = exifMetadata.Data;

                            if (exifInfo.GPSData != null)
                            {
                                // set altitude, latitude and longitude to null values
                                exifInfo.GPSData.Altitude     = null;
                                exifInfo.GPSData.Latitude     = null;
                                exifInfo.GPSData.LatitudeRef  = null;
                                exifInfo.GPSData.Longitude    = null;
                                exifInfo.GPSData.LongitudeRef = null;
                            }
                            exifInfo.BodySerialNumber = "";
                            exifInfo.CameraOwnerName  = "";
                            exifInfo.CFAPattern       = new byte[] { 0 };
                        }
                        else
                        {
                            exifMetadata = new ExifMetadata();
                        }
                        try
                        {
                            //Remove XMP data...
                            XmpPacketWrapper xmpPacket = xmpMetadata.XmpPacket;
                            if (xmpPacket != null)
                            {
                                if (xmpPacket.ContainsPackage(Namespaces.DublinCore))
                                {
                                    // if not - add DublinCore schema
                                    xmpPacket.AddPackage(new DublinCorePackage());
                                    DublinCorePackage dublinCorePackage = (DublinCorePackage)xmpPacket.GetPackage(Namespaces.DublinCore);
                                    dublinCorePackage.Clear();
                                    xmpMetadata.XmpPacket = xmpPacket;
                                }
                            }
                        }
                        catch { }

                        //Update Exif info...
                        try
                        {
                            MetadataUtility.UpdateMetadata(filePath, exifMetadata);
                        }
                        catch { }

                        //Update XMP data...
                        try
                        {
                            MetadataUtility.UpdateMetadata(filePath, xmpMetadata);
                        }
                        catch { }

                        //Remove custom metadata if any...
                        MetadataUtility.CleanMetadata(filePath);

                        return("1");
                    }
                    else if (format.Type.ToString().ToLower() == "png")
                    {
                        //Get XMP data...
                        XmpMetadata xmpMetadata = (XmpMetadata)MetadataUtility.ExtractSpecificMetadata(filePath, MetadataType.XMP);
                        try
                        {
                            //Remove XMP metadata...
                            XmpPacketWrapper xmpPacket = xmpMetadata.XmpPacket;
                            if (xmpPacket != null)
                            {
                                if (xmpPacket.ContainsPackage(Namespaces.DublinCore))
                                {
                                    // if not - add DublinCore schema
                                    xmpPacket.AddPackage(new DublinCorePackage());
                                    DublinCorePackage dublinCorePackage = (DublinCorePackage)xmpPacket.GetPackage(Namespaces.DublinCore);
                                    dublinCorePackage.Clear();
                                    xmpMetadata.XmpPacket = xmpPacket;

                                    //Update XMP metadata in file...
                                    MetadataUtility.UpdateMetadata(filePath, xmpMetadata);

                                    //Clean custom metadata if any...
                                    MetadataUtility.CleanMetadata(filePath);
                                }
                            }
                        }
                        catch { }

                        return("1");
                    }
                    else if (format.Type.ToString().ToLower() == "gif")
                    {
                        //Initialie GifFormat...
                        GifFormat gifFormat = new GifFormat(filePath);

                        //Check if Xmp supported...
                        if (gifFormat.IsSupportedXmp)
                        {
                            //Get XMP data...
                            XmpMetadata xmpMetadata = (XmpMetadata)MetadataUtility.ExtractSpecificMetadata(filePath, MetadataType.XMP);
                            try
                            {
                                XmpPacketWrapper xmpPacket = xmpMetadata.XmpPacket;
                                if (xmpPacket != null)
                                {
                                    if (xmpPacket.ContainsPackage(Namespaces.DublinCore))
                                    {
                                        // if not - add DublinCore schema
                                        xmpPacket.AddPackage(new DublinCorePackage());
                                        DublinCorePackage dublinCorePackage = (DublinCorePackage)xmpPacket.GetPackage(Namespaces.DublinCore);
                                        dublinCorePackage.Clear();
                                        xmpMetadata.XmpPacket = xmpPacket;

                                        //Update Xmp data in file...
                                        MetadataUtility.UpdateMetadata(filePath, xmpMetadata);
                                        //Clean custom metadata if any...
                                        MetadataUtility.CleanMetadata(filePath);
                                    }
                                }
                            }
                            catch { }
                        }
                        return("1");
                    }
                    else
                    {
                        return("Format not supported.");
                    }
                }
                catch (Exception exp)
                {
                    MessageBox.Show("Exception: " + exp.Message);
                    return(exp.Message);
                }
            }
            catch (Exception exp)
            {
                return(exp.Message);
            }
        }
示例#8
0
        public void AddExifValues(PropertyItem[] items)
        {
            if (items.Length == 0)
            {
                return;
            }

            short id = unchecked((short)items[0].Id);

            for (int i = 1; i < items.Length; ++i)
            {
                if (unchecked((short)items[i].Id) != id)
                {
                    throw new ArgumentException("all PropertyItem instances in items must have the same id");
                }
            }

            string[] names = new string[items.Length];

            OnChanging();
            ++suppressChangeEvents;

            for (int i = 0; i < items.Length; ++i)
            {
                names[i] = GetUniqueExifName();
                string blob = PdnGraphics.SerializePropertyItem(items[i]);
                SetValueConcrete(ExifSectionName, names[i], blob);
            }

            object idObj = (object)id; // avoid boxing twice
            ExifInfo info = (ExifInfo)this.exifIdToExifInfo[idObj];

            if (info == null)
            {
                PropertyItem[] newItems = new PropertyItem[items.Length];

                for (int i = 0; i < newItems.Length; ++i)
                {
                    newItems[i] = PdnGraphics.ClonePropertyItem(items[i]);
                }

                info = new ExifInfo(names, newItems);
            }
            else
            {
                string[] names2 = new string[info.names.Length + names.Length];
                PropertyItem[] items2 = new PropertyItem[info.items.Length + items.Length];

                info.names.CopyTo(names2, 0);
                names.CopyTo(names2, info.names.Length);

                info.items.CopyTo(items2, 0);

                for (int i = 0; i < items.Length; ++i)
                {
                    items2[i + info.items.Length] = PdnGraphics.ClonePropertyItem(items[i]);
                }

                info = new ExifInfo(names2, items2);
            }

            this.exifIdToExifInfo[idObj] = info;

            --suppressChangeEvents;
            OnChanged();
        }
示例#9
0
        void loadimageinfo()
        {
            {
                var fi = new FileInfo(filename);
                fi.OpenRead();
                dataGridView1.Rows.Add("File Name", fi.Name);
                dataGridView1.Rows.Add("File Size", fi.Length.ToString() + " Byte(s)");
            }

            ExifInfo exifinfo = null;

            try
            {
                exifinfo = JsonConvert.DeserializeObject <ExifInfo>(exifinfo_raw);
            }
            catch (Exception) { }

            try
            {
                dataGridView1.Rows.Add("Shooting Date", exifinfo.Datetime);
            }
            catch (Exception) { }

            try
            {
                dataGridView1.Rows.Add("Image Size", exifinfo.ImageWidth.ToString() + "x" + exifinfo.ImageHeight.ToString());
            }
            catch (Exception) { }

            try
            {
                dataGridView1.Rows.Add("Manufacturer", exifinfo.Make);
            }
            catch (Exception) { }

            try
            {
                dataGridView1.Rows.Add("Device", exifinfo.Model);
            }
            catch (Exception) { }

            try
            {
                dataGridView1.Rows.Add("Lens", exifinfo.Camera);
            }
            catch (Exception) { }

            try
            {
                dataGridView1.Rows.Add("Software", exifinfo.Software);
            }
            catch (Exception) { }

            try
            {
                dataGridView1.Rows.Add("Aperture", "f/" + exifinfo.FNumber);
            }
            catch (Exception) { }

            try
            {
                dataGridView1.Rows.Add("Focal Length", exifinfo.FocalLength + " mm");
            }
            catch (Exception) { }

            try
            {
                dataGridView1.Rows.Add("35mm Focal Length", exifinfo.FocalLengthIn35mm + " mm");
            }
            catch (Exception) { }

            try
            {
                dataGridView1.Rows.Add("Exposure Time", "1/" + ((int)((double)1 / exifinfo.ExposureTime)).ToString() + " Second(s)");
            }
            catch (Exception) { }

            try
            {
                dataGridView1.Rows.Add("ISO", exifinfo.ISOSpeedRatings);
            }
            catch (Exception) { }

            try
            {
                switch (exifinfo.ExposureProgram)
                {
                case 0:
                    dataGridView1.Rows.Add("Exposure Program", "Undefined");
                    break;

                case 1:
                    dataGridView1.Rows.Add("Exposure Program", "Manual");
                    break;

                case 2:
                    dataGridView1.Rows.Add("Exposure Program", "Auto");
                    break;

                case 3:
                    dataGridView1.Rows.Add("Exposure Program", "Aperture Priority");
                    break;

                case 4:
                    dataGridView1.Rows.Add("Exposure Program", "Shutter Priority");
                    break;

                case 5:
                    dataGridView1.Rows.Add("Exposure Program", "Creative Program");
                    break;

                case 6:
                    dataGridView1.Rows.Add("Exposure Program", "Action Program");
                    break;

                case 7:
                    dataGridView1.Rows.Add("Exposure Program", "Portrait Mode");
                    break;

                case 8:
                    dataGridView1.Rows.Add("Exposure Program", "Landscape Mode");
                    break;

                default:
                    dataGridView1.Rows.Add("Exposure Program", "Unknown");
                    break;
                }
            }
            catch (Exception) { }

            try
            {
                if (exifinfo.Flash)
                {
                    dataGridView1.Rows.Add("Flash", "On");
                }
                else
                {
                    dataGridView1.Rows.Add("Flash", "Off");
                }
            }
            catch (Exception) { }

            try
            {
                dataGridView1.Rows.Add("Latitude", exifinfo.Latitude);
            }
            catch (Exception) { }

            try
            {
                dataGridView1.Rows.Add("Longitude", exifinfo.Longitude);
            }
            catch (Exception) { }

            try
            {
                dataGridView1.Rows.Add("Altitude", exifinfo.Altitude + " Meter(s)");
            }
            catch (Exception) { }
        }
示例#10
0
        public void AddExifValues(PropertyItem[] items)
        {
            if (items.Length == 0)
            {
                return;
            }

            short id = unchecked ((short)items[0].Id);

            for (int i = 1; i < items.Length; ++i)
            {
                if (unchecked ((short)items[i].Id) != id)
                {
                    throw new ArgumentException("all PropertyItem instances in items must have the same id");
                }
            }

            string[] names = new string[items.Length];

            OnChanging();
            ++suppressChangeEvents;

            for (int i = 0; i < items.Length; ++i)
            {
                names[i] = GetUniqueExifName();
                string blob = PdnGraphics.SerializePropertyItem(items[i]);
                SetValueConcrete(ExifSectionName, names[i], blob);
            }

            object   idObj = (object)id; // avoid boxing twice
            ExifInfo info  = (ExifInfo)this.exifIdToExifInfo[idObj];

            if (info == null)
            {
                PropertyItem[] newItems = new PropertyItem[items.Length];

                for (int i = 0; i < newItems.Length; ++i)
                {
                    newItems[i] = PdnGraphics.ClonePropertyItem(items[i]);
                }

                info = new ExifInfo(names, newItems);
            }
            else
            {
                string[]       names2 = new string[info.names.Length + names.Length];
                PropertyItem[] items2 = new PropertyItem[info.items.Length + items.Length];

                info.names.CopyTo(names2, 0);
                names.CopyTo(names2, info.names.Length);

                info.items.CopyTo(items2, 0);

                for (int i = 0; i < items.Length; ++i)
                {
                    items2[i + info.items.Length] = PdnGraphics.ClonePropertyItem(items[i]);
                }

                info = new ExifInfo(names2, items2);
            }

            this.exifIdToExifInfo[idObj] = info;

            --suppressChangeEvents;
            OnChanged();
        }
示例#11
0
        private ExifInfo ReadExifInfoFromBitmapMetadata(BitmapMetadata metaData)
        {
            // Exif情報作成
            ExifInfo exifInfo = new ExifInfo();

            // 撮影日時(原画像データの生成日時)
            try { exifInfo.DateTaken = DateTime.Parse(metaData.DateTaken); }
            catch { return(exifInfo); }

            // カメラメーカー
            try { exifInfo.CameraMaker = metaData.CameraManufacturer; }catch { }

            // カメラ
            try { exifInfo.CameraModel = metaData.CameraModel; }
            catch { }

            // ソフトウェア
            try { exifInfo.Software = metaData.ApplicationName; }
            catch { }

            // 回転情報
            string query_orientation = "/app1/ifd/exif:{uint=274}";

            if (metaData.ContainsQuery(query_orientation))
            {
                switch (Convert.ToUInt32(metaData.GetQuery(query_orientation)))
                {
                case 1:
                    // 回転・反転なし
                    break;

                case 3:
                    // 180度回転
                    exifInfo.Rotation = Rotation.Rotate180;
                    break;

                case 6:
                    // 時計回りに90度回転
                    exifInfo.Rotation = Rotation.Rotate90;
                    break;

                case 8:
                    // 時計回りに270度回転
                    exifInfo.Rotation = Rotation.Rotate270;
                    break;

                case 2:
                    // 水平方向に反転
                    exifInfo.ScaleTransform = new ScaleTransform(-1, 1, 0, 0);
                    break;

                case 4:
                    // 垂直方向に反転
                    exifInfo.ScaleTransform = new ScaleTransform(1, -1, 0, 0);
                    break;

                case 5:
                    // 時計回りに90度回転 + 水平方向に反転
                    exifInfo.Rotation       = Rotation.Rotate90;
                    exifInfo.ScaleTransform = new ScaleTransform(-1, 1, 0, 0);
                    break;

                case 7:
                    // 時計回りに270度回転 + 水平方向に反転
                    exifInfo.Rotation       = Rotation.Rotate270;
                    exifInfo.ScaleTransform = new ScaleTransform(-1, 1, 0, 0);
                    break;
                }
            }

            return(exifInfo);
        }
示例#12
0
        void loadimageinfo()
        {
            {
                var fi = new FileInfo(filename);
                fi.OpenRead();
                dataGridView1.Rows.Add("文件名", fi.Name);
                dataGridView1.Rows.Add("文件大小", fi.Length.ToString() + "字节");
            }

            ExifInfo exifinfo = null;

            try
            {
                exifinfo = JsonConvert.DeserializeObject <ExifInfo>(exifinfo_raw);
            }
            catch (Exception) { }

            try
            {
                dataGridView1.Rows.Add("拍摄日期", exifinfo.Datetime);
            }
            catch (Exception) { }

            try
            {
                dataGridView1.Rows.Add("图像大小", exifinfo.ImageWidth.ToString() + "x" + exifinfo.ImageHeight.ToString());
            }
            catch (Exception) { }

            try
            {
                dataGridView1.Rows.Add("制造商", exifinfo.Make);
            }
            catch (Exception) { }

            try
            {
                dataGridView1.Rows.Add("设备", exifinfo.Model);
            }
            catch (Exception) { }

            try
            {
                dataGridView1.Rows.Add("镜头", exifinfo.Camera);
            }
            catch (Exception) { }

            try
            {
                dataGridView1.Rows.Add("软件", exifinfo.Software);
            }
            catch (Exception) { }

            try
            {
                dataGridView1.Rows.Add("光圈", "f/" + exifinfo.FNumber);
            }
            catch (Exception) { }

            try
            {
                dataGridView1.Rows.Add("焦距", exifinfo.FocalLength + "毫米");
            }
            catch (Exception) { }

            try
            {
                dataGridView1.Rows.Add("35毫米焦距", exifinfo.FocalLengthIn35mm + "毫米");
            }
            catch (Exception) { }

            try
            {
                dataGridView1.Rows.Add("曝光时间", "1/" + ((int)((double)1 / exifinfo.ExposureTime)).ToString() + "秒");
            }
            catch (Exception) { }

            try
            {
                dataGridView1.Rows.Add("感光度", exifinfo.ISOSpeedRatings);
            }
            catch (Exception) { }

            try
            {
                switch (exifinfo.ExposureProgram)
                {
                case 0:
                    dataGridView1.Rows.Add("曝光程序", "未定义");
                    break;

                case 1:
                    dataGridView1.Rows.Add("曝光程序", "手动");
                    break;

                case 2:
                    dataGridView1.Rows.Add("曝光程序", "自动");
                    break;

                case 3:
                    dataGridView1.Rows.Add("曝光程序", "光圈优先");
                    break;

                case 4:
                    dataGridView1.Rows.Add("曝光程序", "快门优先");
                    break;

                case 5:
                    dataGridView1.Rows.Add("曝光程序", "Creative Program");
                    break;

                case 6:
                    dataGridView1.Rows.Add("曝光程序", "Action Program");
                    break;

                case 7:
                    dataGridView1.Rows.Add("曝光程序", "人像模式");
                    break;

                case 8:
                    dataGridView1.Rows.Add("曝光程序", "Landscape Mode");
                    break;

                default:
                    dataGridView1.Rows.Add("曝光程序", "未知");
                    break;
                }
            }
            catch (Exception) { }

            try
            {
                if (exifinfo.Flash)
                {
                    dataGridView1.Rows.Add("闪光灯", "开启");
                }
                else
                {
                    dataGridView1.Rows.Add("闪光灯", "关闭");
                }
            }
            catch (Exception) { }

            try
            {
                dataGridView1.Rows.Add("纬度", exifinfo.Latitude);
            }
            catch (Exception) { }

            try
            {
                dataGridView1.Rows.Add("经度", exifinfo.Longitude);
            }
            catch (Exception) { }

            try
            {
                dataGridView1.Rows.Add("海拔高度", exifinfo.Altitude + "米");
            }
            catch (Exception) { }
        }