【问题标题】:rmagick rotate and resize to fit specified dimensions in papercliprmagick 旋转和调整大小以适合回形针中的指定尺寸
【发布时间】: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


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-02-13
      • 2011-09-30
      • 2017-05-21
      • 1970-01-01
      • 2019-06-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多