在线帮助 ICP备案 合作机构 我要订制
 
 7×24客服热线:13663712063
您的位置:首页  技术支持 C#实现根据图片的EXIF自动调整图片方向
       越辰家政管理软件
       越辰空调售后管理软件
       越辰图书销售管理软件
       越辰物业管理软件
       越辰茶楼管理软件
       越辰幼儿园管理软件
       越辰餐饮管理软件
       越辰病历管理系统
       越辰洗浴管理软件
       越辰住院管理系统
       越辰超市管理系统
  

C#实现根据图片的EXIF自动调整图片方向

来源:yocin  时间:2012-3-22 8:58:52  栏目:技术支持  点击率:1144

一、什么是 EXIF

  

Exif
是英文Exchangeable Image File(可交换图像文件)的缩写,最初由日本电子工业发展协会(JEIDA --Japan Electronic Industry Development Association) 制订,目前的最新版本是发表于2002年04月的2.21 版。国际标准化组织(ISO)正在制订的相机文件设计标准(DCF -- Design role for Camera File system)可能以Exif2.1为基础。

      所有的JPEG文件以字符串“0xFFD8”开头,并以字符串“0xFFD9”结束。文件头中有一系列“0xFF??”格式的字符串,称为“标识”,用来标记JPEG文件的信息段。“0xFFD8”表示图像信息开始,“0xFFD9”表示图像信息结束,这两个标识后面没有信息,而其它标识紧跟一些信息字符。

  0xFFE0 -- 0xFFEF之间的标识符称为“应用标记”,没有被常规JPEG文件利用,Exif正是利用这些信息串记录拍摄信息如快门速度、光圈值等,甚至可以包括全球定位信息。其中拍摄方向的ID为“0x0112”,有1至8共8种值。



二、EXIF Orientation


Orientation 
The image orientation viewed in terms of rows and columns. 
Tag = 274 (112.H) 
Type = SHORT 
Count = 1 
Default = 1 
1 = The 0th row is at the visual top of the image, and the 0th column is the visual left-hand side. 
2 = The 0th row is at the visual top of the image, and the 0th column is the visual right-hand side. 
3 = The 0th row is at the visual bottom of the image, and the 0th column is the visual right-hand side. 
4 = The 0th row is at the visual bottom of the image, and the 0th column is the visual left-hand side. 
5 = The 0th row is the visual left-hand side of the image, and the 0th column is the visual top. 
6 = The 0th row is the visual right-hand side of the image, and the 0th column is the visual top. 
7 = The 0th row is the visual right-hand side of the image, and the 0th column is the visual bottom. 
8 = The 0th row is the visual left-hand side of the image, and the 0th column is the visual bottom. 
Other = reserved


一、使用C#旋转图片

       public static void rotating(Bitmap img,ref int width, ref int height, int orien)
        
{
            
int ow = width;
            
switch (orien)
            
{
                
case 2:
                    img.RotateFlip(RotateFlipType.RotateNoneFlipX);
//horizontal flip
                    break;
                
case 3:
                    img.RotateFlip(RotateFlipType.Rotate180FlipNone);
//right-top
                    break;
                
case 4:
                    img.RotateFlip(RotateFlipType.RotateNoneFlipY);
//vertical flip
                    break;
                
case 5:
                    img.RotateFlip(RotateFlipType.Rotate90FlipX);
                    
break;
                
case 6:
                    img.RotateFlip(RotateFlipType.Rotate90FlipNone);
//right-top
                    width = height;
                    height 
= ow;
                    
break;
                
case 7:
                    img.RotateFlip(RotateFlipType.Rotate270FlipX);
                    
break;
                
case 8:
                    img.RotateFlip(RotateFlipType.Rotate270FlipNone);
//left-bottom
                    width = height;
                    height 
= ow;
                    
break;
                
default:
                    
break;
            }

        }
上一篇:C#获取图像Exif信息   下一篇:经典.NET面试题
Copyright ◎2008-2018郑州越辰科技有限公司 版权所有 网站地图
地址:中国·河南郑州市文化路交北环路北晨e时代B座505室 
电话:0371-63399049 13663712063 备案号:豫ICP备19031456号
我们专注于 软件开发| 网站制作  返回欢迎页 
  
点击这里给我发消息 越辰业务
点击这里给我发消息 越辰业务
点击这里给我发消息 越辰代理
点击这里给我发消息 越辰技术
 ,页面执行时间:15.625毫秒        
up close

返回顶部

越辰科技微信
微信扫一扫