什么是RMagick等效于ImageMagic命令

时间:2013-11-07 16:36:27

标签: ruby imagemagick rmagick

什么是RMagick等效于ImageMagic命令:

compare -metric AE -fuzz 25% img1.png img2.png result.png

以下ruby代码工作正常,它为我提供了所需的浮点值,但生成的图像不受模糊影响。

img1       = Magick::Image.read("img1.png").first
img2       = Magick::Image.read("img1.png").first
img1.fuzz  = "25%"
img, float = img1.compare_channel(img2, Magick::AbsoluteErrorMetric)
img.save('result.png')

1 个答案:

答案 0 :(得分:0)

我认为它确实可以正常使用它。我正在使用rmagick(2.13.3)

这样的sg对我有用,可供比较。 玩弄模糊,它确实有所作为......

require 'RMagick'
require 'pp'

include Magick
a = ImageList.new("/path/to/ref/asset/missing-thumbnail.jpg")
b = ImageList.new("https://url-to-check.com/getAssetImage/objId:2225296/videoVersionId:2225297/type:cover/width:138/height:200/imageId:2247209.jpg")
c = ImageList.new("/path/to/second/asset/imageId:189577.jpg")
#a.display
#b.display
c.fuzz = '20%'
diff = c.compare_channel(b, Magick::AbsoluteErrorMetric) 
if  diff[1] == 0
  puts "yeeey. they r identical..."
else
  puts "ojh. they r not the same..."
  #pp diff 
  puts diff[1]
end
exit