class User < ActiveRecord::Base

  has_attached_file :photo, :styles => { :square => "100%", :large => "100%" },
    :convert_options => {
      :square => "-auto-orient -geometry 70X70#",
      :large => "-auto-orient -geometry X300" },
    :storage  => :s3,
    :s3_credentials => "#{RAILS_ROOT}/config/s3.yml",
    :path => ":attachment/:id/:style.:extension",
    :bucket => 'mybucket'

  validates_attachment_size :photo,
    :less_than => 5.megabyte

end

作品本地机器上很大,但给了我在Heroku上的错误:There was an error processing the thumbnail for stream.20143 问题是我想调整之前自动东方的照片,让他们调整正确。

现在唯一的工作变体(感谢jonnii)是在调整无自动定向:

...
as_attached_file :photo, :styles => { :square => "70X70#", :large => "X300" },
        :storage  => :s3,
        :s3_credentials => "#{RAILS_ROOT}/config/s3.yml",
        :path => ":attachment/:id/:style.:extension",
        :bucket => 'mybucket'
...

如何通过附加的转换选项回形针在Heroku?

<强> UPD

我发现,在“ - 自动定向”选项的麻烦。好像这个选项是由Heroku的使用ImageMagick的版本打破。我创建从纸夹的标准缩略图继承自定义回形针图像处理器:

module Paperclip

  class Ao < Thumbnail

    def transformation_command
      super + " -auto-orient"
    end

   end
end

它可以完美的本地计算机上,但未能在Heroku上。

有帮助吗?

解决方案

这些是我使用的大小。他们都很好地工作在Heroku:

SIZES = {
  :original => "640x480>",
  :thumb => "150x150#",
  :mini => "60x60#",
  :micro => "30x30#"
}

确认的回形针是一样的Heroku的你的宝石版本。您可以在.gems文件并在environment.rb指定特定的宝石版本,以确保他们排队。

我不知道到底为什么你convert_options导致问题的,但如果我没有记错的回形针直接使用ImageScience和您所选择的选项可能是与只读Heroku的文件系统不兼容。

如果这是至关重要的,你需要一个答案,现在我养在Heroku支持票。如果你得到的响应确保你将它张贴回来!

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top