2012-02-22 8 views
0

私はPaperclipからCarrierwaveに移行しています。ここで私は、サムネイルの世代のための処理コマンドを変換しようとしています:サムネイル生成ルールをpaperclipからcarrierwaveに変換する方法

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 
関連する問題