2012-02-22 68 views
0

我正在從回形針移植到載波。這裏我試圖轉換處理縮略圖的命令:如何將縮略圖生成規則從回形針轉換爲載波

has_attached_file :image, 
    styles: { 
     thumb: '220x140#', 
     big: '620x600>', 
     no_proportion: '255x162!' 
    }, 
    convert_options: { 
     all: '-strip', 
     thumb: '-delete 1--1', 
     no_proportion: '-delete 1--1' 
    } 

我打算使用MiniMagick。我得到了我從220x140#轉換爲resize_to_fill(220,140),但我不知道如何轉換所有其他命令。

P.S.如果我可以重新使用現有的ImageMagick命令和參數,即使是調整大小(即不使用內置的助手大小調整器),情況會更好。

回答

0

我已經完成了以下工作。但是我不確定它是否完全相同。

process :strip 

    # Create different versions of your uploaded files: 
    version :thumb do 
    process :resize_to_fill => [220,140] 
    end 
    version :mobile do 
    process :resize_to_fill => [320,210] 
    end 
    version :mobile_small do 
    process :resize_to_fill => [256,168] 
    end 
    version :big do 
    process :resize_to_limit => [620,600] 
    end 
    version :groupbuy_ad do 
    process :resize_to_fill => [96,60] 
    end 
    version :email do 
    process :resize_to_fill => [125,125] 
    end 
    version :widget_165 do 
    process :resize_to_fill => [165,105] 
    end 
    version :widget_100 do 
    process :resize_to_fill => [100,64] 
    end 
    version :no_proportion do 
    process :resize => '255x162!' 
    end 

    def strip 
    manipulate! do |img| 
     img.strip 
     img = yield(img) if block_given? 
     img 
    end 
    end 

    def resize(dimension) 
    manipulate! do |img| 
     img.resize dimension 
     img = yield(img) if block_given? 
     img 
    end 
    end 

    def get_first_frame 
    manipulate! do |img| 
     img = img.delete '1--1' 
    end 
    end