Sha256: 98e8c76f7bd4abe719f5ff5da56db04a243046b181918e0926ff488a028947e8

Contents?: true

Size: 908 Bytes

Versions: 1

Compression:

Stored size: 908 Bytes

Contents

# frozen_string_literal: true

require "chunky_png"
require "capybara/screenshot/diff/difference"

module Capybara
  module Screenshot
    module Diff
      # Compare two images and determine if they are equal, different, or within some comparison
      # range considering color values and difference area size.
      module Drivers
        class BaseDriver
          PNG_EXTENSION = ".png"

          def same_dimension?(comparison)
            dimension(comparison.base_image) == dimension(comparison.new_image)
          end

          def height_for(image)
            image.height
          end

          def width_for(image)
            image.width
          end

          def image_area_size(image)
            width_for(image) * height_for(image)
          end

          def dimension(image)
            [width_for(image), height_for(image)]
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
capybara-screenshot-diff-1.9.0 lib/capybara/screenshot/diff/drivers/base_driver.rb