From 605c7d467f07cf541cbe60d28f45a793ff5c2e88 Mon Sep 17 00:00:00 2001 From: Ruling-Mac Date: Mon, 20 Jul 2015 16:21:49 +0800 Subject: [PATCH] fix orientation problem --- app/uploaders/gallery_uploader.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/uploaders/gallery_uploader.rb b/app/uploaders/gallery_uploader.rb index a87ac5f..0fa4968 100644 --- a/app/uploaders/gallery_uploader.rb +++ b/app/uploaders/gallery_uploader.rb @@ -32,6 +32,11 @@ class GalleryUploader < CarrierWave::Uploader::Base "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" end + def fix_exif_rotation + manipulate! do |img| + img.tap(&:auto_orient) + end + end # Provide a default URL as a default if there hasn't been a file uploaded: # def default_url # "/images/fallback/" + [version_name, "default.png"].compact.join('_') @@ -50,14 +55,17 @@ class GalleryUploader < CarrierWave::Uploader::Base # end version :thumb do + process :fix_exif_rotation process :resize_to_fill => [200, 200] end version :theater do + process :fix_exif_rotation process :resize_to_limit => [1920, 1080] end version :mobile do + process :fix_exif_rotation process :resize_to_limit => [1152, 768] end @@ -81,6 +89,6 @@ class GalleryUploader < CarrierWave::Uploader::Base # rescue ::MiniMagick::Error, ::MiniMagick::Invalid => e # raise CarrierWave::ProcessingError.new("Failed to manipulate with MiniMagick, maybe it is not an image? Original Error: #{e}") # end - + end