【问题标题】:Rails Paperclip - Can't get thumbnail to resize properlyRails Paperclip - 无法正确调整缩略图大小
【发布时间】:2011-07-04 23:06:59
【问题描述】:

我在创建缩略图时遇到了困难,由于某种原因,它没有按照我想要的方式截断。我通常发布风景照片,因此尺寸正确,但是当照片必须自动旋转时,它就不起作用了。

has_attached_file  :image, :styles => {   :mobile_lg => "640x480>",
                                          :mobile_sm => "200x150#",
                                          :thumb => "96x96#"
                                          },
                   :convert_options => { :all => '-auto-orient' },
                   :storage => :s3,
                   :s3_credentials => "#{RAILS_ROOT}/config/s3.yml",
                   :path => "/:style/:id/:filename"

不要嘲笑这张照片,这是我唯一的例子!这是mobile_lg 照片。

还有mobile_sm的照片:

缩略图应该是这样的(我在 Photoshop 中这样裁剪)

我尝试在样式之后添加它,但它不起作用。

:commands => { :mobile_sm => "-gravity center -extent 200x150#" }

我想拍摄照片并将其裁剪/调整为 200(宽度)乘 150(高度),即使这意味着破坏性地这样做。我也尝试在尺寸之后使用!,但我仍然得到了您在上面看到的 mobile_sm 图像。

【问题讨论】:

    标签: ruby-on-rails image-processing imagemagick paperclip


    【解决方案1】:

    我猜你正在寻找类似的东西:

    :small =>  { :mobile_sm => '150x200!', :quality => 70, :format => 'JPG'}
    

    看看这里:http://www.imagemagick.org/script/command-line-processing.php

    它总结了 Paperclip 使用的 ImageMagick 所能做的一切。

    顺便说一句,我喜欢这张照片;)

    【讨论】:

      猜你喜欢
      • 2014-04-03
      • 1970-01-01
      • 1970-01-01
      • 2012-05-25
      • 2011-11-19
      • 1970-01-01
      • 2019-05-06
      • 2014-09-21
      • 1970-01-01
      相关资源
      最近更新 更多