phash-rb 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2ed6783979b46e09e95389897750228c77636def24aca69d4317bdefe2084d87
4
- data.tar.gz: fd24447815072b2c2327c08611db9ff92f26a334064a610c93a5074db3a45b61
3
+ metadata.gz: 995d2669bfb1ed93482da8a528db5da15a4a01095ab4b04798a7a8bd2ef2d207
4
+ data.tar.gz: 6abdafea8b495b031378b22b36bba58a1b69bcef263fa1f8981fd2dd3c774828
5
5
  SHA512:
6
- metadata.gz: 82b859cbc9d5bd00dc452e7c62e33e0b74a6015be8276a9954300c2391727604dd6726a96bcbe276e04e23a3176c36cb3e78e1167934e595f2cf094127d13551
7
- data.tar.gz: bce7b097bb1c3f370fe2622fb375064b086f4e264347f61d5da6ed03a2e54aba72f66a99341a496e7a298c8e1f61231cd6adfe6705c01e5c015dbec95fcdd31b
6
+ metadata.gz: 7416ab673a2218b225a138e4934d7ca117af2617256d8ffeb8919ad54a23b18025b81795d1f1f3e592532f823bf30db3cca127acc22abd6fb0c4dd07f7ed9552
7
+ data.tar.gz: 47830995008c37150316b48c08504747ece664d652fae7116752d1ec996fd53f444b612c70ff3a447e97e2e36a3946c62edc6d87eafc8564bf9b4636f2f878e4
data/CHANGELOG.md ADDED
@@ -0,0 +1,11 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ ### 0.2.0
6
+
7
+ Allow passing Vips::Image directly to fingerprint function
8
+
9
+ ### 0.1.0
10
+
11
+ Initial version
data/README.md CHANGED
@@ -1,9 +1,16 @@
1
1
  # Phash
2
2
 
3
- Phashion replacement without native dependencies. Compatible with pHash 0.9.6.
3
+ [![Gem Version](https://badge.fury.io/rb/phash-rb.svg)](https://badge.fury.io/rb/phash-rb)
4
+ [![Test](https://github.com/khasinski/phash-rb/workflows/Phash-rb/badge.svg)](https://github.com/khasinski/phash-rb/actions/workflows/main.yml)
4
5
 
5
- ## Installation
6
+ Phashion replacement without native extension (however it currently relies on libvips). Compatible with pHash 0.9.6.
7
+
8
+ ## Requirements
6
9
 
10
+ - libvips (see requirements for [ruby-vips](https://github.com/libvips/ruby-vips))
11
+ - Ruby 3.0.0 or later
12
+
13
+ ## Installation
7
14
 
8
15
  ```bash
9
16
  bundle add phash-rb
@@ -48,10 +55,16 @@ Phash::Image.new(filename1).fingerprint # 3714852948054213970
48
55
  Fingerprint is also available in a command `phash`:
49
56
 
50
57
  ```bash
51
- $ phash filename1
58
+ $ phash test/fixtures/test.jpg
52
59
  3714852948054213970
53
60
  ```
54
61
 
62
+ Additionally you can pass `Vips::Image` directly to fingerprint function:
63
+ ```ruby
64
+ image.class # Vips::Image
65
+ Phash::Image.new(image).fingerprint # 3714852948054213970
66
+ ```
67
+
55
68
  ## Development
56
69
 
57
70
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
data/lib/phash/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Phash
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
data/lib/phash.rb CHANGED
@@ -10,8 +10,8 @@ module Phash
10
10
  CIMG_V = CIMG_PI / 2 / 32
11
11
  CIMG_SCALE = 2**8 + 1
12
12
 
13
- def self.fingerprint(file)
14
- img = Vips::Image.new_from_file(file)
13
+ def self.fingerprint(path_or_img)
14
+ img = path_or_img.is_a?(Vips::Image) ? path_or_img : Vips::Image.new_from_file(path_or_img)
15
15
  #Y = (66*R + 129*G + 25*B + 128)/256 + 16
16
16
  img = img * [66.0 / 256, 129.0 / 256, 25.0 / 256]
17
17
  r, g, b = img.bandsplit
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phash-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomasz Ratajczak
8
8
  - Krzysztof Hasiński
9
- autorequire:
10
9
  bindir: exe
11
10
  cert_chain: []
12
- date: 2025-01-22 00:00:00.000000000 Z
11
+ date: 1980-01-02 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: ruby-vips
@@ -48,6 +47,7 @@ executables:
48
47
  extensions: []
49
48
  extra_rdoc_files: []
50
49
  files:
50
+ - CHANGELOG.md
51
51
  - CODE_OF_CONDUCT.md
52
52
  - LICENSE.txt
53
53
  - README.md
@@ -63,7 +63,6 @@ metadata:
63
63
  homepage_uri: http://github.com/khasinski/phash-rb
64
64
  source_code_uri: http://github.com/khasinski/phash-rb
65
65
  changelog_uri: http://github.com/khasinski/phash-rb
66
- post_install_message:
67
66
  rdoc_options: []
68
67
  require_paths:
69
68
  - lib
@@ -78,8 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
78
77
  - !ruby/object:Gem::Version
79
78
  version: '0'
80
79
  requirements: []
81
- rubygems_version: 3.5.22
82
- signing_key:
80
+ rubygems_version: 3.6.7
83
81
  specification_version: 4
84
82
  summary: Ruby implementation of pHash library
85
83
  test_files: []