我遵循jcrop rails教程,但我碰到了一個障礙。事實上,回形針是從原始文件生成縮略圖,但我需要它從另一種樣式生成。原始文件在產品鏡頭和文檔邊緣之間沒有空格。所以我不能進一步收穫。爲了解決這個問題,我製作了另一種具有白色像素填充的風格。這就是我想從中生成縮略圖的原因。Rails回形針從其他風格生成縮略圖
# croppable is the one with the padding...it's what shows up in the crop view.
# I want :thumb to be generated from THAT style, not :original.
# When generating from :original, the crop offset/size is screwed because the dimensions of :original don't match :cropped
# and I can't crop beyond the pixel dimensions of :original.
has_attached_file :photo, :styles => {
:thumb => { :geometry => "300x300#", :format => :jpg, :processors => [:cropper] },
:general => ["150x375", :jpg],
:show => ["x425", :jpg],
:croppable => ["1200x1200>", :jpg]
},
:url => "/assets/wines/:style/:wine_name",
:path => ":rails_root/public:url",
:default_url => ":wine_default",
:default_path => ":rails_root/public:wine_default",
: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 -unsharp 0.3x0.3+5+0'
},
:processors => [:thumbnail, :compression]