سؤال

All I essentially want to do, is to crop an image using jcrop, then with those dimensions, rotate the image -30deg and save the thumbnail. However rmagick creates additional pixels due to the fact that there's no scaling involved after the rotation. I'd like to know how to achieve that.

# 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]

What I eventually want to do is to rotate the preview image via css transform, so that the preview actually shows what the thumbnail will look like after cropping. At this point I'm not sure how to get what I want when it comes to paperclip saving the thumbnail and rotating it.

هل كانت مفيدة؟

المحلول

No answer found. I ended up switching to Carrierwave and encountering another set of problems which I've finally arrived at a solution for. Too bad Carrierwave doesn't log the processing of images, but that's a small price to pay.

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top