zoukankan      html  css  js  c++  java
  • C# exif 信息

    C# exif 信息

    复制代码
    public void FindExifinfo(string filePath)
    {
    
                Image img = Image.FromFile(filePath);
    
                PropertyItem[] pt = img.PropertyItems;
    
                for (int i = 0; i < pt.Length; i++)
    
                {
    PropertyItem p = pt[i];             
    
                    switch (pt[i].Id)
    
    {  // 设备制造商 20.  
    
                        case 0x010F:
    
                            this.textBox1.Text = System.Text.ASCIIEncoding.ASCII.GetString(pt[i].Value);
    
                            break;            
    case 0x0110: // 设备型号 25.  
    
                            this.textBox4.Text = GetValueOfType2(p.Value);
    
                            break;
    
                        case 0x0132: // 拍照时间 30.
    
                            this.textBox2.Text = GetValueOfType2(p.Value);
    
                            break;          
    
                        case 0x829A: // .曝光时间  
    
        this.textBox3.Text = GetValueOfType5(p.Value)+" sec";
    
                            break;
                      case 0x8827: // ISO 40.   
    
                            this.textBox5.Text = GetValueOfType3(p.Value);
    
                            break;
    
                        case 0x010E: // 图像说明info.description
    
                            this.textBox6.Text = GetValueOfType2(p.Value);
    
                            break;
    
                        case 0x920a: //相片的焦距
    
                            this.textBox7.Text = GetValueOfType5A(p.Value) + " mm";
    
                            break;
                        case 0x829D: //相片的光圈值
    
                            this.textBox8.Text = GetValueOfType5A(p.Value);
    
                            break;
    
                        default:
    
                            break; 
    
    } 
    
          }
    
    }
    
    
    

    public string GetValueOfType2(byte[] b)// 对type=2 的value值进行读取

    
    

            {

    
    

                return System.Text.Encoding.ASCII.GetString(b);

    
    

            }

    private static string GetValueOfType3(byte[] b) //对type=3 的value值进行读取

            {

                if (b.Length != 2) return "unknow";

                return Convert.ToUInt16(b[1] << 8 | b[0]).ToString();

            }

           private static string GetValueOfType5(byte[] b) //对type=5 的value值进行读取

            {

                if (b.Length != 8) return "unknow";

                UInt32 fm, fz;

                fm = 0;

                fz = 0;

                fz = Convert.ToUInt32(b[7] << 24 | b[6] << 16 | b[5] << 8 | b[4]);

                fm = Convert.ToUInt32(b[3] << 24 | b[2] << 16 | b[1] << 8 | b[0]);

                return fm.ToString() + "/" + fz.ToString()+" sec";

            }

    private static string GetValueOfType5A(byte[] b)//获取光圈的值

            {

                if (b.Length != 8) return "unknow";

                UInt32 fm, fz;

                fm = 0;

                fz = 0;

                fz = Convert.ToUInt32(b[7] << 24 | b[6] << 16 | b[5] << 8 | b[4]);

                fm = Convert.ToUInt32(b[3] << 24 | b[2] << 16 | b[1] << 8 | b[0]);

                double temp = (double)fm / fz;

                return (temp).ToString();

            }

    
    
    复制代码
  • 相关阅读:
    window查看已保存过的wifi的密码
    js 多个数组取交集
    macOS APP 窗口焦点监听
    proxifier注册码
    天才算法之睡眠排序(C#实现)
    Tomcat 7使用AJP协议设置问题
    nginx启动报错(1113: No mapping for the Unicode character exists in the target multi-byte code page)
    八皇后的n种放置方法
    insufficient permission for adding an object to repository database .git/objects
    centos下搭建php开发环境(lamp)
  • 原文地址:https://www.cnblogs.com/xianyin05/p/3071368.html
Copyright © 2011-2022 走看看