Rails image_tag旋转图像 [英] Rails image_tag rotates image
本文介绍了Rails image_tag旋转图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我将Amazon S3用于配置了载波和雾的图像存储.这些图像似乎可以正确存储,但是当我有一个人像"图像(宽度小于高度)时,它不能正确显示,而是在侧面旋转图像.
I am using Amazon's S3 for image storage with carrierwave and fog configured. The images seem to store correctly however when I have a 'portrait' image (smaller width than height) it is not displaying correctly, but rather rotating the image on its side.
任何朝着正确方向的指针将不胜感激!
Any pointers in the right direction would be much appreciated!
uploaders/image_uploader.rb
uploaders/image_uploader.rb
class ImageUploader < CarrierWave::Uploader::Base
include CarrierWave::RMagick
include Sprockets::Helpers::RailsHelper
include Sprockets::Helpers::IsolatedHelper
storage :fog
include CarrierWave::MimeTypes
process :set_content_type
process :resize_to_limit => [420, 0]
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
def extension_white_list
%w(jpg jpeg png)
end
end
show.html.haml
show.html.haml
= image_tag(@idea.image_attachments.first.image.url).to_s
image_attachment.rb
image_attachment.rb
class ImageAttachment < ActiveRecord::Base
require 'carrierwave/orm/activerecord'
attr_accessible :image, :description
belongs_to :image_attachable, polymorphic: true
mount_uploader :image, ImageUploader
end
推荐答案
在uploader.rb文件中,尝试
in the uploader.rb file, try
process :auto_orient
def auto_orient
manipulate! do |image|
image.tap(&:auto_orient)
end
end
它应该修复它.
这篇关于Rails image_tag旋转图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文