I’ve recently encountered a problem where a user uploads an image and somewhere along the lines, paperclip is flipping it upside down.
The image in question can be seen here http://photoramblr.com/photos/36
As you see, the image is upside-down; but drag the image to your desktop and it will appear rightside-up. Since this image was taken on an iPhone I can only assume this is related to the image’s orientation setting on the iPhone. Has anyone encountered anything like this or have any suggestions on how to address this?
The code here is pretty straightforward Paperclip lingo:
class Photo < ActiveRecord::Base
has_attached_file :image,
:storage => :s3,
:s3_credentials => S3_CREDENTIALS,
:styles => {
:thumb => "100x100#",
:small => "138x138>",
:large => "580x580>",
:x_large => "1600x1600>"}
Update
Hm, I was able to fix this by taking a screenshot of the image and uploading that. There must have been something in the meta-data that was setting the correct orientation that didn’t make its way through.
Yes, this is a problem we solved last week where I work. 🙂 If you’re using ImageMagick/RMagic for image processing, you can use
Image#auto_orientto “rotate or flip the image based on the image’s EXIF orientation tag”; call this method on the image in a Paperclip processor and you should be good to go.[Edit]
You may be interested in Rails, Paperclip, -auto-orient, and resizing…. I also found it interesting that CarrierWave made this process very easy: