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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b9dd21b28b731fe1b65ba352b65d3bd8b3a30e78
4
- data.tar.gz: 51d1ba2da83dc157ed92ff3659a2538cf13bae32
3
+ metadata.gz: 465577547953c3039cdea1665f7010ed0af57656
4
+ data.tar.gz: 9bb9a40feba3b039d0c0ee12f94907dd9b23fa68
5
5
  SHA512:
6
- metadata.gz: 4444959377a750dad3da8fd98547d258a4cd2be46488c1a312a859f19eca6261810be4c3ef023d5c8f1681d8262dec12c9a0d6ef5ee0818e6b1bdbe538bfbd19
7
- data.tar.gz: 62ab37e14c953b3382f3a66c1b661d6c8ff3c20fa8aac2b86e4bdd1d82d5ef601c5f9c5c5485eb76bd90dd4e9049355fffc4f3f62604eb710391881e064fdf1e
6
+ metadata.gz: 5936ffe730fb274a719d812dde7dab4113c5002d3c7acaad3c58bb12ed8d1da5744f7afa9d73e728ad7b54ee14f5f1f300bf021d98eab64ed08fefbeeb5034e2
7
+ data.tar.gz: 19d272fa20c2f954f111561537328f677fbb32a84836e4d03d605f1086c3694b27647390b9420b36ce4fe56c7ddd8537f247729464202a0ba8a968813670237e
data/Gemfile CHANGED
@@ -1,5 +1,3 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem "ruby-vips", github: "libvips/ruby-vips"
4
-
5
3
  gemspec
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
- FileUtils.mkdir_p dir = "images"
4
- "#{dir}/#{image}".tap do |filename|
5
- require "digest" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.5.0")
6
- unless File.exist?(filename) && Digest::MD5.file(filename) == File.basename(filename, ".jpg")
7
- open("https://storage.googleapis.com/dhash-vips.nakilon.pro/#{image}") do |link|
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
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "dhash-vips"
3
- spec.version = "0.1.0.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
 
@@ -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
@@ -63,7 +63,7 @@ require "dhash-vips"
63
63
  ].each do |images, min, max|
64
64
 
65
65
  require "fileutils"
66
- require "digest" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.5.0")
66
+ require "digest"
67
67
  require "mll"
68
68
 
69
69
  require_relative "common"
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.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: 2019-12-22 00:00:00.000000000 Z
11
+ date: 2020-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-vips