问题
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