Rails Paperclip - 无法正确调整缩略图大小
我在创建缩略图时遇到困难,由于某种原因,它没有按照我想要的方式进行切割。我通常发布风景照片,以便尺寸正确,但是当照片必须自动旋转时,它不起作用。
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.
and the mobile_sm
photo:
When the thumbnail should be like this (i cropped it like this in Photoshop)
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我猜你正在寻找类似的东西:
看看这里: http:// www.imagemagick.org/script/command-line-processing.php
它总结了使用 Paperclip 使用的 ImageMagick 可以执行的所有操作。
顺便说一句,我喜欢这张照片;)
I guess you're looking for something like:
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 ;)