我有一个应用程序让你拍照并上传到我们的服务器。问题是有时图片是颠倒的,有时是向左或向右旋转。我怎么能纠正这个?如何在上传后旋转图像以使其在计算机上看起来正常?感谢。
答案 0 :(得分:2)
你有很多解决方案:
答案 1 :(得分:-1)
以下是我在服务器上轮换的方式:
Dim rft As RotateFlipType = RotateFlipType.RotateNoneFlipNone
Dim properties As PropertyItem() = img.PropertyItems
For Each prop As PropertyItem In properties
'274 is the exif id for camera orientation
If prop.Id = 274 Then
Dim orientation As Short = BitConverter.ToInt16(prop.Value, 0)
Select Case orientation
Case 1
rft = RotateFlipType.RotateNoneFlipNone
Exit Select
Case 3
rft = RotateFlipType.Rotate180FlipNone
Exit Select
Case 6
rft = RotateFlipType.Rotate90FlipNone
Exit Select
Case 8
rft = RotateFlipType.Rotate270FlipNone
Exit Select
End Select
Exit For
End If
Next
If rft <> RotateFlipType.RotateNoneFlipNone Then
img.RotateFlip(rft)
End If
Return rft