pixel_matcher 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +2 -0
- data/images/screen_shot.jpeg +0 -0
- data/lib/pixel_matcher/diff_image.rb +17 -18
- data/lib/pixel_matcher/version.rb +1 -1
- data/lib/pixel_matcher.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4625b9a182bfacda310566d8369343374ebdf78aa370a8f9ce2f482f057b8464
|
4
|
+
data.tar.gz: f23bc22210b46b58739c298d4858293b248e82b6e67035763d1a246a0a13ad9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '08e08719ee337d8a72d2e45cbc7926b8e5d4d658116185ee0b6b711103917fb479f7525544b968fe82b0999c14eb669a0e0b209ca78542122231f3e68a491371'
|
7
|
+
data.tar.gz: 4a24ea644f3dde937b0b09ab3b2a9db99a21af3b63623c81d00d22657dccc4f46897924f331349e756f5f94cb37ceee17004f96ea3b61960f4226a10d02add5c
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
Binary file
|
@@ -1,35 +1,42 @@
|
|
1
1
|
require 'rmagick'
|
2
2
|
|
3
3
|
module PixelMatcher
|
4
|
-
class DiffImage
|
4
|
+
class DiffImage < Magick::Image
|
5
5
|
def initialize(img1, img2)
|
6
|
+
self.class.image_size_validate(img1, img2)
|
6
7
|
@img1 = img1
|
7
8
|
@img2 = img2
|
8
|
-
@
|
9
|
-
|
9
|
+
super(@img1.columns, @img1.rows) { self.background_color = 'none' }
|
10
|
+
store_diff
|
10
11
|
end
|
11
12
|
|
12
13
|
def self.from_path(path1, path2)
|
13
14
|
img1 = Magick::Image.read(path1).first
|
14
15
|
img2 = Magick::Image.read(path2).first
|
15
|
-
|
16
|
+
new(img1, img2)
|
16
17
|
end
|
17
18
|
|
18
19
|
def self.from_blob(bin1, bin2)
|
19
20
|
img1 = Magick::Image.from_blob(bin1).first
|
20
21
|
img2 = Magick::Image.from_blob(bin2).first
|
21
|
-
|
22
|
+
new(img1, img2)
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.image_size_validate(img1, img2)
|
26
|
+
return if [img1.columns, img1.rows] == [img2.columns, img2.rows]
|
27
|
+
|
28
|
+
raise PixelMatcher::SizeMismatchError, 'Image size mismatch'
|
22
29
|
end
|
23
30
|
|
24
31
|
def export_diff(output_path)
|
25
|
-
|
26
|
-
@diff.write(output_path)
|
32
|
+
write(output_path)
|
27
33
|
self
|
28
34
|
end
|
29
35
|
|
30
36
|
def export_gray_scale(output_path)
|
31
|
-
|
32
|
-
|
37
|
+
gray_scale = @img1.clone.quantize(256, Magick::GRAYColorspace)
|
38
|
+
gray_scale.composite!(self, Magick::CenterGravity, 0, 0, Magick::OverCompositeOp);
|
39
|
+
gray_scale.write(output_path)
|
33
40
|
self
|
34
41
|
end
|
35
42
|
|
@@ -38,15 +45,7 @@ module PixelMatcher
|
|
38
45
|
def store_diff
|
39
46
|
@img1.columns.times do |i|
|
40
47
|
@img1.rows.times do |j|
|
41
|
-
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def store_gray_scale_diff
|
47
|
-
@img1.columns.times do |i|
|
48
|
-
@img1.rows.times do |j|
|
49
|
-
@gray_scale.store_pixels(i, j, 1, 1, [@img1.pixel_color(i, j)]) unless eq_pixel?(i, j)
|
48
|
+
store_pixels(i, j, 1, 1, [@img1.pixel_color(i, j)]) unless eq_pixel?(i, j)
|
50
49
|
end
|
51
50
|
end
|
52
51
|
end
|
data/lib/pixel_matcher.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pixel_matcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ksk001100
|
@@ -112,6 +112,7 @@ files:
|
|
112
112
|
- Rakefile
|
113
113
|
- bin/console
|
114
114
|
- bin/setup
|
115
|
+
- images/screen_shot.jpeg
|
115
116
|
- lib/pixel_matcher.rb
|
116
117
|
- lib/pixel_matcher/diff_image.rb
|
117
118
|
- lib/pixel_matcher/version.rb
|