rmagick旋转并调整大小以适合回形针中的指定尺寸

问题描述 投票:0回答:1

[我基本上要做的就是使用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
1个回答
0
投票

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

Carrierwave RMagick not removing transparency in convert to jpgCarrierwave +repage option not working

© www.soinside.com 2019 - 2024. All rights reserved.