Sha256: da5df3b56c4fbbd62961e32d8d6da4301b008a7993078fe77002ca72745caef8

Contents?: true

Size: 613 Bytes

Versions: 1

Compression:

Stored size: 613 Bytes

Contents

module Similatron
  class ImagemagickComparisonEngine < ComparisonEngine

    def can_handle_mime?(mime_type)
      mime_type =~ /image/
    end

    private

    def default_executable_path
      "compare"
    end

    def diff_extension
      "jpg"
    end

    def command(expected, actual, diff_path)
      "#{executable_path} -metric PSNR #{expected} #{actual} #{diff_path}"
    end

    def diff(exec_result)
      exec_result.status == 1 ? diff_path : nil
    end

    def score(exec_result)
      if exec_result.status == 2
        100
      else
        exec_result.err.to_i
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
similatron-0.2.0 lib/similatron/imagemagick_comparison_engine.rb