Class: Capybara::Screenshot::Diff::Drivers::VipsDriver::VipsUtil
- Inherits:
-
Object
- Object
- Capybara::Screenshot::Diff::Drivers::VipsDriver::VipsUtil
- Defined in:
- lib/capybara/screenshot/diff/drivers/vips_driver.rb
Class Method Summary collapse
- .difference(old_image, new_image, color_distance: 0) ⇒ Object
- .difference_area(old_image, new_image, color_distance: 0) ⇒ Object
- .difference_area_size_by(difference_mask) ⇒ Object
- .difference_mask(color_distance, old_image, new_image) ⇒ Object
- .difference_region_by(diff_mask) ⇒ Object
Class Method Details
.difference(old_image, new_image, color_distance: 0) ⇒ Object
148 149 150 151 |
# File 'lib/capybara/screenshot/diff/drivers/vips_driver.rb', line 148 def self.difference(old_image, new_image, color_distance: 0) diff_mask = difference_mask(color_distance, new_image, old_image) difference_region_by(diff_mask) end |
.difference_area(old_image, new_image, color_distance: 0) ⇒ Object
153 154 155 156 |
# File 'lib/capybara/screenshot/diff/drivers/vips_driver.rb', line 153 def self.difference_area(old_image, new_image, color_distance: 0) difference_mask = difference_mask(color_distance, new_image, old_image) difference_area_size_by(difference_mask) end |
.difference_area_size_by(difference_mask) ⇒ Object
158 159 160 161 |
# File 'lib/capybara/screenshot/diff/drivers/vips_driver.rb', line 158 def self.difference_area_size_by(difference_mask) diff_mask = difference_mask == 0 diff_mask.hist_find.to_a[0][0].max end |
.difference_mask(color_distance, old_image, new_image) ⇒ Object
163 164 165 |
# File 'lib/capybara/screenshot/diff/drivers/vips_driver.rb', line 163 def self.difference_mask(color_distance, old_image, new_image) (new_image - old_image).abs > color_distance end |
.difference_region_by(diff_mask) ⇒ Object
167 168 169 170 171 172 173 174 175 176 |
# File 'lib/capybara/screenshot/diff/drivers/vips_driver.rb', line 167 def self.difference_region_by(diff_mask) columns, rows = diff_mask.project left = columns.profile[1].min right = columns.width - columns.flip("horizontal").profile[1].min top = rows.profile[0].min bottom = rows.height - rows.flip("vertical").profile[0].min [left, top, right, bottom] end |