Sha256: 0ad5e03f34aa98e07327402c78e22ade3401bb6536b02d7055148da579c81057

Contents?: true

Size: 588 Bytes

Versions: 3

Compression:

Stored size: 588 Bytes

Contents

class ImageMatcher
  attr_reader :fuzz_factor, :diff_file_name
  def initialize(options={})
    @fuzz_factor = options.fetch(:fuzz_factor, 0)
    @diff_file_name = options.fetch(:diff_file_name, './temp.png')
  end

  def identical?(source, target)
    compare_command = "compare -fuzz #{fuzz_factor}% -metric AE -dissimilarity-threshold 1 -subimage-search"
    out = `#{compare_command} \"#{source}\" \"#{target}\" \"#{diff_file_name}\" 2>&1`
    out.chomp!
    out.start_with?('0')
  end

  def cleanup
    if File.exist?(diff_file_name)
      `rm #{diff_file_name}`
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
motion-juxtapose-0.3.2 lib/juxtapose/image_matcher.rb
motion-juxtapose-0.3.1 lib/juxtapose/image_matcher.rb
motion-juxtapose-0.3.0 lib/juxtapose/image_matcher.rb