2

自从升级到 Ruby 1.9.3、Rails 3.1.0.rc4 和 Paperclip 3.4.0 后,我的应用程序图像渲染出现了严重问题。

无论我给 Paperclip 提供何种设置变化,链接到下面的 infile 都会变得模糊,如链接的 outfile 所示。

输出文件必须适合 620x412 的盒子,如此处所示

链接到输入文件

链接到此代码生成的输出文件

该模型的完整代码如下...

class Propertyimage < ActiveRecord::Base

  belongs_to :property

  validates_presence_of :description
  validates_presence_of :sortorder

  has_attached_file :image, :styles => { :export => {:geometry => "620x412#", :quality =>    100, :format => 'JPG'} },
  :path => ":rails_root/public/system/:attachment/:id/:style/:filename",
  :url => "/system/:attachment/:id/:style/:filename"
end
4

1 回答 1

1

我遇到了类似的问题,经过大量试验和错误后,我能够使用三个标准进行修复:图像大小规范、convert_options 和缩放图像。例如,在您的 Propertyimage 类中尝试:

has_attached_file :image, 
  :styles => { :original => ["640x480", :jpg], :export => {:geometry => "620x412#", :quality => 100, :format => 'JPG'} },
  :convert_options => { :all => "-quality 100" },
  :path => ":rails_root/public/system/:attachment/:id/:style/:filename",
  :url => "/system/:attachment/:id/:style/:filename"

然后您可以使用图像标签的大小,或者在我使用 PDF 的情况下,Id 使用了 scale 选项:

pdf.image the_file_name, :at => [0, 720], :scale => 0.75
于 2013-02-07T05:00:02.500 回答