0

我基本上想要做的就是使用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 变换旋转预览图像,以便预览实际显示裁剪后缩略图的样子。在这一点上,当涉及到回形针保存缩略图并旋转它时,我不确定如何获得我想要的东西。

4

1 回答 1

0

没有找到答案。我最终切换到 Carrierwave 并遇到了另一组问题,我终于找到了解决方案。太糟糕了 Carrierwave 不记录图像的处理,但这是一个很小的代价。

Carrierwave RMagick 在转换为 jpg 时不删除透明度
Carrierwave +repage 选项不起作用

于 2013-10-28T19:39:02.933 回答