我最近遇到了一个问题,用户上传了一张图片,但是在某个地方,Paperclip把它翻转了。您可以在这里看到相关的图片http://photoramblr.com/photos/36。正如您所见,图片是倒置的;但是将该图像拖到桌面上,它就会正常显示。由于这张图片是在iPhone上拍摄的,我只能认为这与iPhone上的图像定向设置有关。有人遇到过类似的情况吗?或者对如何解决这个问题有什么建议吗?这里的代码非常简单直接,就是Paperclip行话。
class Photo < ActiveRecord::Base
has_attached_file :image,
:storage => :s3,
:s3_credentials => S3_CREDENTIALS,
:styles => {
:thumb => "100x100#",
:small => "138x138>",
:large => "580x580>",
:x_large => "1600x1600>"}
更新
嗯,我通过截取图像并上传来解决了这个问题。可能是元数据中的某些信息没有正确传递导致了方向不正确的问题。
def rotate manipulate! do |img| img.auto_orient img = yield(img) if block_given? img end end
- anuimage.tap(&:auto_orient)
,否则我会得到NoMethodError: undefined method
destroy!' for true:TrueClass`。 - Besi