将imagemagick命令转换为rmagick

时间:2016-03-27 05:26:58

标签: ruby imagemagick rmagick

我需要帮助将以下imagemagick命令转换为rmagick。任何帮助或见解表示赞赏。

convert rose: -background black -gravity south -splice 0x8 \
          \( +clone -sparse-color barycentric '0,0 black 69,0 white' \) \
          \( +clone -function arcsin 0.5 \) \
          \( -clone 1 -level 25%,75% \
                 -function polynomial -4,4,0 -gamma 2 \
                 +level 50%,0 \) \
          -delete 1 -swap 0,1  miff:- |\
     composite - -virtual-pixel black  -displace 17x7  rose_cylinder.png

http://www.imagemagick.org/Usage/mapping/#displace_cylinder

基本上会有两个图像,一个是圆柱形状,一个是杯子,另一个图像是圆柱形放在杯子形状上。

感谢。

更新: 这是我正在尝试构建的代码。

base_image = "/home/mon/ruby/images/cylinder.png" 
design_image = "/home/mon/ruby/images/design.png" 
bg = Magick::Image.read(base_image).first 
img = Magick::Image.new(500, 600) { 
  self.background_color = 'white' 
} 
img = img.composite bg, 0, 0, Magick::OverCompositeOp 
design = Magick::Image.read(design_image).first 
design.background_color = 'transparent' 
design.gravity = SouthGravity 
design = design.splice("0x8") 
design1 = design.clone.sparse_color(Magick::BarycentricColorInterpolate, 0, 0, "black", 69, 0, "white") 
design2 = design1.clone.function_channel Magick::ArcsinFunction, 0.5

0 个答案:

没有答案