载波未定义方法 auto_orient
Carrierwave undefined metho auto_orient
我一直在尝试使用 RMagick auto_orient 方法来修复移动上传。目前它们旋转了 90 度。我的上传器文件目前看起来像这样。
class AvatarUploader < CarrierWave::Uploader::Base
include CarrierWave::RMagick
storage :fog
def root
Rails.root.join 'public/'
end
include CarrierWave::MimeTypes
process :set_content_type
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
process :resize_to_fill => [200, 200]
version :thumb do
process :resize_to_fill => [50, 50]
end
process :auto_orient
def extension_white_list
%w(jpg jpeg gif png)
end
end
这给我一个错误
undefined local variable or method auto_orient for AvatarUploader:Class (NameError)
我尝试了几种解决方案,
exif image rotation issue using carrierwave and rmagick to upload to s3, https://github.com/minimagick/minimagick/issues/68
但没有骰子。
有人知道我做错了什么吗?
尝试添加以下内容:
def auto_orient
manipulate! do |img|
img.auto_orient!
end
end
就目前而言,您引用的 auto_orient
进程在上下文中不存在,因此出现错误。
编辑:根据您发布的 imagemagick github link,auto_orient!
可能已损坏。然后您可以以类似的方式使用 auto_orient
(它只是创建一个新图像而不是修改传递给该方法的图像)。请参阅您发布的 links,了解使用 auto_orient
方法的可能解决方案。
我一直在尝试使用 RMagick auto_orient 方法来修复移动上传。目前它们旋转了 90 度。我的上传器文件目前看起来像这样。
class AvatarUploader < CarrierWave::Uploader::Base
include CarrierWave::RMagick
storage :fog
def root
Rails.root.join 'public/'
end
include CarrierWave::MimeTypes
process :set_content_type
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
process :resize_to_fill => [200, 200]
version :thumb do
process :resize_to_fill => [50, 50]
end
process :auto_orient
def extension_white_list
%w(jpg jpeg gif png)
end
end
这给我一个错误
undefined local variable or method auto_orient for AvatarUploader:Class (NameError)
我尝试了几种解决方案, exif image rotation issue using carrierwave and rmagick to upload to s3, https://github.com/minimagick/minimagick/issues/68 但没有骰子。
有人知道我做错了什么吗?
尝试添加以下内容:
def auto_orient
manipulate! do |img|
img.auto_orient!
end
end
就目前而言,您引用的 auto_orient
进程在上下文中不存在,因此出现错误。
编辑:根据您发布的 imagemagick github link,auto_orient!
可能已损坏。然后您可以以类似的方式使用 auto_orient
(它只是创建一个新图像而不是修改传递给该方法的图像)。请参阅您发布的 links,了解使用 auto_orient
方法的可能解决方案。