对于任何需要这个的人,我基本上使用 VB.Net 中的代码解决了这个问题。我发现这正是我所需要的:
Public Function TestRotate(sImageFilePath As String) As Boolean
Dim rft As RotateFlipType = RotateFlipType.RotateNoneFlipNone
Dim img As Bitmap = Image.FromFile(sImageFilePath)
Dim properties As PropertyItem() = img.PropertyItems
Dim bReturn As Boolean = False
For Each p As PropertyItem In properties
If p.Id = 274 Then
Dim orientation As Short = BitConverter.ToInt16(p.Value, 0)
Select Case orientation
Case 1
rft = RotateFlipType.RotateNoneFlipNone
Case 3
rft = RotateFlipType.Rotate180FlipNone
Case 6
rft = RotateFlipType.Rotate90FlipNone
Case 8
rft = RotateFlipType.Rotate270FlipNone
End Select
End If
Next
If rft <> RotateFlipType.RotateNoneFlipNone Then
img.RotateFlip(rft)
System.IO.File.Delete(sImageFilePath)
img.Save(sImageFilePath, System.Drawing.Imaging.ImageFormat.Jpeg)
bReturn = True
End If
Return bReturn
End Function