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 +4 -4
- data/CHANGELOG.md +11 -0
- data/README.md +16 -3
- data/lib/phash/version.rb +1 -1
- data/lib/phash.rb +2 -2
- metadata +4 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 995d2669bfb1ed93482da8a528db5da15a4a01095ab4b04798a7a8bd2ef2d207
|
4
|
+
data.tar.gz: 6abdafea8b495b031378b22b36bba58a1b69bcef263fa1f8981fd2dd3c774828
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7416ab673a2218b225a138e4934d7ca117af2617256d8ffeb8919ad54a23b18025b81795d1f1f3e592532f823bf30db3cca127acc22abd6fb0c4dd07f7ed9552
|
7
|
+
data.tar.gz: 47830995008c37150316b48c08504747ece664d652fae7116752d1ec996fd53f444b612c70ff3a447e97e2e36a3946c62edc6d87eafc8564bf9b4636f2f878e4
|
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -1,9 +1,16 @@
|
|
1
1
|
# Phash
|
2
2
|
|
3
|
-
|
3
|
+
[](https://badge.fury.io/rb/phash-rb)
|
4
|
+
[](https://github.com/khasinski/phash-rb/actions/workflows/main.yml)
|
4
5
|
|
5
|
-
|
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
|
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
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(
|
14
|
-
img = Vips::Image.new_from_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.
|
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:
|
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.
|
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: []
|