Photos uploaded by mobile with carreirwave/dropzone are rotated correctly in s3 but are showing up sideways on my webapp

被刻印的时光 ゝ 提交于 2019-12-12 01:13:34

问题


When a User uploads photos with a mobile phone using Carrierwave/Dropzone the photos will sometimes be sideways in the preview, however the photos are being saved in s3 with the correct rotation. However, despite being saved in s3 with the correct rotation, when they are then shown on the web app, they are again being shown sideways. Very confusing.


回答1:


Here's the code to get it working

class AvatarUploader < CarrierWave::Uploader::Base
  include CarrierWave::MiniMagick    
  process :auto_orient

  def auto_orient
    manipulate! do |image|
      image.tap(&:auto_orient)
    end
  end

end

Side note: auto_orient does not work retroactively, images need to be re-uploaded for them to have the proper orientation.



来源:https://stackoverflow.com/questions/42862741/photos-uploaded-by-mobile-with-carreirwave-dropzone-are-rotated-correctly-in-s3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!