I have an app that let's you take pictures and upload them to our server. The problem is sometimes the pictures are upside down, sometimes are rotated left or right. How can i correct this? How can I rotate the image so that it looks ok on the computer after uploaded? Thanks.
Asked
Active
Viewed 885 times
2 Answers
2
You have many solutions:
- the first is to simply use the current iPhone orientation when the photo is taken. This post should help you. Then use this information to rotate the image when taken on the iPhone.
- you can also read the EXIF data send to treat this information on the server side.
- you can also use some javascript to read this EXIF value (which might not be portable).
-
Thanks for the answer for me the most simple was to read the exif data from the uploaded image and rotate on the server. I also tryed rotating the image on the iPhone but then it doesn't look good on the phone only on the computer. – gyozo kudor Sep 14 '10 at 12:37
-1
Here is how i rotated on the server:
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

gyozo kudor
- 6,284
- 10
- 53
- 80
-
Please give a reason for the downvote, maybe I can help or correct it if it's wrong. – gyozo kudor Sep 13 '11 at 12:11
-
For one thing, looping through each property item to find the one you want is inefficient. I would think there would be a way to get the specific property item without the iteration. – Obi Wan Oct 11 '13 at 13:36
-
-
This is actually a good solution and I think a satisfactory answer to the question posed. Seeing this was very helpful to me in overcoming a similar problem I am having with unwanted orientation issues related to mobile device images. – Obi Wan Oct 11 '13 at 13:50