Rails Paperclip - 无法正确调整缩略图大小

发布于 2024-10-19 12:14:50 字数 1180 浏览 1 评论 0原文

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

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 图像。

I'm having difficulty creating a thumbnail, for some reason it's not chopping off the way I want. I typically post landscape photos so the dimensions are correct, however when the photo has to be auto rotated, it's not working.

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"

Don't laugh at the pic, it's my only example! Here's the mobile_lg photo.

enter image description here

and the mobile_sm photo:

enter image description here

When the thumbnail should be like this (i cropped it like this in Photoshop)

enter image description here

I've tried to add this after the styles, but it's not working.

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

I would like to take the photo and crop/resize it to 200(width) by 150(height), even if it means doing it destructively. I've also tried to use ! after the dimensions, but still I get the mobile_sm image you see above.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

愿得七秒忆 2024-10-26 12:14:50

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

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

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

它总结了使用 Paperclip 使用的 ImageMagick 可以执行的所有操作。

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

I guess you're looking for something like:

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

Have a look here: http://www.imagemagick.org/script/command-line-processing.php

It sums up everything you can do with ImageMagick used by Paperclip.

BTW, I like the pic ;)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文