dhash-vips 0.1.0.0 → 0.1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -2
- data/common.rb +7 -10
- data/dhash-vips.gemspec +2 -2
- data/lib/dhash-vips.rb +2 -2
- data/test.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 465577547953c3039cdea1665f7010ed0af57656
|
4
|
+
data.tar.gz: 9bb9a40feba3b039d0c0ee12f94907dd9b23fa68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5936ffe730fb274a719d812dde7dab4113c5002d3c7acaad3c58bb12ed8d1da5744f7afa9d73e728ad7b54ee14f5f1f300bf021d98eab64ed08fefbeeb5034e2
|
7
|
+
data.tar.gz: 19d272fa20c2f954f111561537328f677fbb32a84836e4d03d605f1086c3694b27647390b9420b36ce4fe56c7ddd8537f247729464202a0ba8a968813670237e
|
data/Gemfile
CHANGED
data/common.rb
CHANGED
@@ -1,14 +1,11 @@
|
|
1
|
-
def download_and_keep image
|
1
|
+
def download_and_keep image # returns path
|
2
2
|
require "open-uri"
|
3
|
-
|
4
|
-
"
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
File.open(filename, "wb") do |file|
|
9
|
-
IO.copy_stream link, file
|
10
|
-
end
|
3
|
+
require "digest"
|
4
|
+
File.join(FileUtils.mkdir_p(File.expand_path "images", __dir__()).first, image).tap do |path|
|
5
|
+
open("https://storage.googleapis.com/dhash-vips.nakilon.pro/#{image}") do |link|
|
6
|
+
File.open(path, "wb") do |file|
|
7
|
+
IO.copy_stream link, file
|
11
8
|
end
|
12
|
-
end
|
9
|
+
end unless File.exist?(path) && Digest::MD5.file(path) == File.basename(image, ".jpg")
|
13
10
|
end
|
14
11
|
end
|
data/dhash-vips.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "dhash-vips"
|
3
|
-
spec.version = "0.1.0.
|
3
|
+
spec.version = "0.1.0.1"
|
4
4
|
spec.author = "Victor Maslov"
|
5
5
|
spec.email = "nakilon@gmail.com"
|
6
6
|
spec.summary = "dHash and IDHash powered by Vips"
|
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.license = "MIT"
|
9
9
|
|
10
10
|
spec.test_files = %w{ test.rb }
|
11
|
-
spec.files = `git ls-files -z`.split("\x0") - spec.test_files - %w{ .gitignore }
|
11
|
+
spec.files = `git ls-files -z`.split("\x0") - spec.test_files - %w{ .gitignore } - Dir.glob("example_ocr/**")
|
12
12
|
spec.require_path = "lib"
|
13
13
|
spec.extensions = %w{ extconf.rb }
|
14
14
|
|
data/lib/dhash-vips.rb
CHANGED
@@ -10,7 +10,7 @@ module DHashVips
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def pixelate file, hash_size, kernel = nil
|
13
|
-
image = Vips::Image.new_from_file file
|
13
|
+
image = Vips::Image.new_from_file file, access: :sequential
|
14
14
|
if kernel
|
15
15
|
image.resize((hash_size + 1).fdiv(image.width), vscale: hash_size.fdiv(image.height), kernel: kernel).colourspace("b-w")
|
16
16
|
else
|
@@ -79,7 +79,7 @@ module DHashVips
|
|
79
79
|
|
80
80
|
def fingerprint filename, power = 3
|
81
81
|
size = 2 ** power
|
82
|
-
image = Vips::Image.new_from_file filename
|
82
|
+
image = Vips::Image.new_from_file filename, access: :sequential
|
83
83
|
image = image.resize(size.fdiv(image.width), vscale: size.fdiv(image.height)).colourspace("b-w").flatten
|
84
84
|
|
85
85
|
array = image.to_a.map &:flatten
|
data/test.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dhash-vips
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.
|
4
|
+
version: 0.1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Maslov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-vips
|