通过手机使用carreirwave/dropzone上传的照片在s3中已正确旋转,但在我的webapp中显示为横向 [英] Photos uploaded by mobile with carreirwave/dropzone are rotated correctly in s3 but are showing up sideways on my webapp
问题描述
当用户使用Carrierwave/Dropzone用手机上传照片时,照片有时在预览中会偏斜,但是照片会以正确的旋转方式保存在s3中.但是,尽管它们以正确的旋转方式保存在s3中,但是当它们随后显示在Web应用程序上时,它们还是再次被横向显示.非常混乱.
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.
推荐答案
以下是使其正常工作的代码
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
旁注:auto_orient
无法追溯工作,需要重新上传图像以使其具有正确的方向.
Side note: auto_orient
does not work retroactively, images need to be re-uploaded for them to have the proper orientation.
这篇关于通过手机使用carreirwave/dropzone上传的照片在s3中已正确旋转,但在我的webapp中显示为横向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!