0

什么是 RMagick 等价于 ImageMagic 命令:

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

下面的 ruby​​ 代码工作正常,它给了我想要的浮点值,但生成的图像不会受到 fuzz 的影响。

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')
4

1 回答 1

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
于 2014-09-07T12:30:20.443 回答