I am using carrierwave
as gem for uploading images in my Rails project, it works fine on all devices except Android, whenever I upload an image from an Android device then it gets rotated 90 degree.
These are the gems used to upload image:
gem 'rmagick'
gem 'carrierwave'
And here is the code from the avatar_uploader.rb
# encoding: utf-8
class AvatarUploader < CarrierWave::Uploader::Base
# Include RMagick or MiniMagick support:
include CarrierWave::RMagick
# include CarrierWave::MiniMagick
# Choose what kind of storage to use for this uploader:
storage :file
# storage :fog
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
version :thumb, :if => :image? do
process :crop
resize_to_fill(100, 100)
end
version :large, :if => :image? do
resize_to_limit(600, 600)
end
def crop
if model.crop_x.present?
resize_to_limit(600, 600)
manipulate! do |img|
x = model.crop_x.to_i
y = model.crop_y.to_i
w = model.crop_w.to_i
h = model.crop_h.to_i
img.crop!(x, y, w, h)
end
end
end
protected
def image?(new_file)
new_file.content_type.include? 'image'
end
end