目錄
PropertyItems
代碼
什么是 EXIF
EXIF Orientation
PropertyItems
代碼
/// <summary>
/// 根據(jù)圖片exif調(diào)整方向
/// </summary>
/// <param name="img"></param>
public void RotateImage(Bitmap img)
{
var exif = img.PropertyItems;
byte orien = 0;
var item = exif.Where(m => m.Id == 274).ToArray();
if (item.Length > 0)
orien = item[0].Value[0];
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
break;
case 7:
img.RotateFlip(RotateFlipType.Rotate270FlipX);
break;
case 8:
img.RotateFlip(RotateFlipType.Rotate270FlipNone);//left-bottom
break;
default:
break;
}
}
什么是 EXIF
????????Exif是英文Exchangeable Image File(可交換圖像文件)的縮寫,最初由日本電子工業(yè)發(fā)展協(xié)會(JEIDA --Japan Electronic Industry Development Association) 制訂,目前的最新版本是發(fā)表于2002年04月的2.21 版。國際標準化組織(ISO)正在制訂的相機文件設計標準(DCF -- Design role for Camera File system)可能以Exif2.1為基礎。
????????Exif 文件實際是JPEG文件的一種,遵從JPEG標準,只是在文件頭信息中增加了有關拍攝信息的內(nèi)容和索引圖。所以你可以使用任何支持JPEG格式的圖像工具軟件觀看或修改Exif文件,但,打開時可能看不到Exif信息,一旦修改,Exif信息可能丟失。
????????所有的JPEG文件以字符串“0xFFD8”開頭,并以字符串“0xFFD9”結(jié)束。文件頭中有一系列“0xFF??”格式的字符串,稱為“標識”,用來標記JPEG文件的信息段。“0xFFD8”表示圖像信息開始,“0xFFD9”表示圖像信息結(jié)束,這兩個標識后面沒有信息,而其它標識緊跟一些信息字符。
????????0xFFE0 -- 0xFFEF之間的標識符稱為“應用標記”,沒有被常規(guī)JPEG文件利用,Exif正是利用這些信息串記錄拍攝信息如快門速度、光圈值等,甚至可以包括全球定位信息。其中拍攝方向的ID為“0x0112”,有1至8共8種值。文章來源:http://www.zghlxwxcb.cn/news/detail-622651.html
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文章來源地址http://www.zghlxwxcb.cn/news/detail-622651.html
到了這里,關于C# 根據(jù)圖片的EXIF自動調(diào)整圖片方向的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!