Hello Team,
I have a problem related to image rotation
I have 2 images :
1.FabricHeaderExample.jpg
2.H12532D_ANTIBEE.jpg
For Example 1: FabricHeaderExample.jpg image looks Potraint image, when i upload this image and displaying in Image control.
while displaying it is rotating as landscape. It is having exif data. for this i write a code as below:
- Dim img As Image = Image.FromFile(selectedFileName)
- Dim propid = (From p In img.PropertyItems Where p.Id = 274 Select p).ToList
- If propid IsNot Nothing Then
- For Each pid In propid
- Dim orientationValue As Integer = pid.Value(0)
- Dim rotateFlipType As RotateFlipType = OrientationToFlipType(orientationValue)
- img.RotateFlip(rotateFlipType)
- img.RemovePropertyItem(274)
- Exit For
- Next
- End If
- Private Shared Function OrientationToFlipType(ByVal orientation As String) As RotateFlipType
- Select Case Integer.Parse(orientation)
- Case 1
- Return RotateFlipType.RotateNoneFlipNone
- Case 2
- Return RotateFlipType.RotateNoneFlipX
- Case 3
- Return RotateFlipType.Rotate180FlipNone
- Case 4
- Return RotateFlipType.Rotate180FlipX
- Case 5
- Return RotateFlipType.Rotate90FlipX
- Case 6
- Return RotateFlipType.Rotate90FlipNone
- Case 7
- Return RotateFlipType.Rotate270FlipX
- Case 8
- Return RotateFlipType.Rotate270FlipNone
- Case Else
- Return RotateFlipType.RotateNoneFlipNone
- End Select
- End Function
After that, it displaying properly.
For example 2: H12532D_ANTIBEE.jpg image looks normally image, but it is having exif data am using above code to display image in image control.
but the image is not rotating properly. but both images are getting same orientation value as 6.
I need to fix the code for both images are displaying properly.
Here am uploading sample application, in that application under images folder having above mentioned 2 images.