【发布时间】:2013-10-24 02:03:49
【问题描述】:
我基本上想做的就是使用jcrop 裁剪图像,然后使用这些尺寸,将图像旋转-30 度并保存缩略图。然而,由于旋转后不涉及缩放,rmagick 会创建额外的像素。我想知道如何实现。
# 150 x 150 is the final cropped image I want for my thumb(nails)
# :croppable is a file I use that takes the original and adds white padding in a 1200x1200
# file size so I can actually crop with white space available (you can't crop outside the
# original dimensions of the file)
has_attached_file :photo, :styles => {
:thumb => { :geometry => "150x150#", :format => :jpg, :processors => [:cropper] },
:general => ["150x375", :jpg],
:show => ["x425", :jpg],
:croppable => ["1200x1200>", :jpg]
},
:url => "/assets/w/:style/:w",
:path => ":rails_root/public:url",
:default_url => ":w_default",
:default_path => ":rails_root/public:w",
:default_style => :show,
:convert_options => {
:thumb => '-gravity center -rotate -30',
:croppable => '-gravity center -extent 1200x1200',
:general => '-gravity center -extent 150x375 -quality 95',
:all => '-quality 100 -antialias -flatten -background white -interlace Plane -unsharp 0.3x0.3+5+0'
},
:processors => [:thumbnail, :compression]
我最终想要做的是通过 css 变换旋转预览图像,以便预览实际显示裁剪后缩略图的样子。在这一点上,我不确定如何在回形针保存缩略图和旋转它时得到我想要的。
【问题讨论】:
标签: ruby-on-rails image-processing paperclip rmagick jcrop