I'm using UIImagePickerController to take a photo in portrait mode on the iphone and save to the web. The photo appears in portrait on the phone, but rotates 90 degrees on the web.
If I download the photo and look at it in Preview (mac) or Photoshop (mac or pc) it is in portrait again. In Windows Picture Viewer (pc) it's rotated to landscape.
Do I need to apply a rotation transform to the image data before uploading? Will I then also need to remove the meta-data that's rotating it in Photoshop and in Preview?
Here is a solution for CarrierWavew/MiniMagick: http://carrierwave.rubyforge.org/rdoc/classes/CarrierWave/MiniMagick.html
Once you take the photo before uploading the image to the server just pass your taken image into a method and its surely works for you
The problem was that image rotation was added to the photo as EXIF data not used by most browsers. There are two solutions:
Apply the rotation on the server side. I was using the Ruby plugin Paperclip (by Thoughtbot) and just had to include the auto-orient convert option to the has_attached_file command in the model:
has_attached_file :photo, :convert_options => { :all => '-auto-orient' }
Rotate the photo within the iPhone app. This was solved in another stackoverflow question; calling the scaleAndRotate method replaces the rotation meta-data with an image transform, thanks to @Squeegy.
Here is an easy way to manually override the EXIF rotation metadata, if the image is saved in the correct orientation in MS Windows. In Windows Explorer, right-click on the image file and select "Rotate clockwise". Do this 4 times to rotate the image all the way around, and then the image will have the correct orientation for all systems. Then you can upload the image to your web server.