phashion 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.travis.yml +12 -0
- data/CHANGES.md +6 -0
- data/README.md +16 -20
- data/lib/phashion.rb +3 -0
- data/lib/phashion/version.rb +1 -1
- data/test/test_phashion.rb +21 -0
- metadata +15 -13
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
MDU4NmM0NGQxZmYzMzkxZGQ5ZmYzOTUxYzFhMDk0MjIxYzQ5ZDAzNw==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ebac5ae2ba75fbd9e071287286183bdd5b14d693
|
4
|
+
data.tar.gz: b4fd9ec06089d2d47aab777f76947c4d455d6deb
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
MjJkYTYyNDZiZTYyZWU1NmZhODg4ZDMxNDM3ZTA4YTU2Y2YyOTgzZDA0NDVk
|
11
|
-
OGUzNzg4NWVjODI3ZjQ4ODljMjkyNWYxYmNjYTc1NWQwODExNWY=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NjA2NDI5YTdkMjRmNGQ0ZDgwNDAwZGI5NjA0NTEzNThkY2NlZWFkMDUzMWI5
|
14
|
-
ODM3NWRmN2U1YmViYTUwMjA4ZGE3ZjI3OTVkZjBlZjNiZGZkNWFmZmJlNzc4
|
15
|
-
ZjgzOTM0YWIxMzg4NGUyMDFmNDFlM2E2MDU2ODdkMDc5N2I2Mjc=
|
6
|
+
metadata.gz: 173f5227fd1e05d9013b3ee00ec3ee5fc7ebae6586e8c806e79eba98facccb2b95aa46d389f5a47e63c17aff2c3194cc0860ec562d01af36809a5913b45933e6
|
7
|
+
data.tar.gz: 558e7a2b6f2c36406a196fd60567f8f51c9ad2f05b177f81456ae30a60b4193e479bd1f083438d4bd6638426c235fb8e8f611a6ed5ce9bb2dde27d4c95d6e93f
|
data/.travis.yml
ADDED
data/CHANGES.md
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
History
|
2
2
|
=======
|
3
3
|
|
4
|
+
1.2.0
|
5
|
+
-----
|
6
|
+
* Added TravisCI testing support (issue #49)
|
7
|
+
* Renamed `sqlite_phashion_init` to `sqlite_extension_init` to fixing failing tests (issue #49).
|
8
|
+
See https://github.com/westonplatter/phashion/commit/f821b5f6bb40f438a1ab3f6fcc6f7730366468ae
|
9
|
+
|
4
10
|
1.1.1
|
5
11
|
-----
|
6
12
|
* Added Ruby method to call into pHash's Mexican Hat Wavelet funcition (issue #37, Terence Lee / @hone)
|
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
Phashion
|
2
2
|
========
|
3
|
+
[![Build Status](https://travis-ci.org/westonplatter/phashion.svg?branch=tests-travisci)](https://travis-ci.org/westonplatter/phashion)
|
3
4
|
|
4
5
|
Phashion is a Ruby wrapper around the [pHash library](http://phash.org/), "perceptual hash", which detects duplicate and near-duplicate multimedia files (e.g. images, audio, video, though Phashion currently only supports images.). "Near-duplicates" are images that come from the same source and show essentially the same thing, but may have differences in such features as dimensions, bytesizes, lossy-compression artifacts, and color levels.
|
5
6
|
|
@@ -32,24 +33,19 @@ Please open a [GitHub issue](https://github.com/westonplatter/phashion/issues/)
|
|
32
33
|
|
33
34
|
### Prerequisites
|
34
35
|
|
35
|
-
|
36
|
-
-
|
37
|
-
-
|
38
|
-
|
39
|
-
If you're on a Mac, you can use:
|
36
|
+
Linux
|
37
|
+
- libjpeg-dev
|
38
|
+
- libpng-dev
|
40
39
|
|
41
|
-
|
42
|
-
-
|
40
|
+
Mac
|
41
|
+
- [imagemagick](http://www.imagemagick.org/)
|
42
|
+
- libjpeg (Hombrew, `brew install libjpeg`; Macports, `port install jpeg`)
|
43
43
|
|
44
44
|
|
45
45
|
#### Common Errors
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
- `ld: library not found for -ljpeg` – You need to install `libjpeg` if you run into this error upon `gem install`:
|
50
|
-
|
51
|
-
|
52
|
-
- `.....sh: convert: command not found; sh: gm: command not found` – You need to install [imagemagick](http://www.imagemagick.org/).
|
46
|
+
- `ld: library not found for -ljpeg` – Did you install `libjpeg`?
|
47
|
+
- `... sh: convert: command not found; sh: gm: command not found` – Did you install [imagemagick](http://www.imagemagick.org/)?
|
48
|
+
- `... checking for sqlite3ext.h... *** extconf.rb failed *** ...` – Did you install `libpng-dev` and/or `libjpeg-dev`?
|
53
49
|
|
54
50
|
|
55
51
|
Usage
|
@@ -84,7 +80,7 @@ Optionally, you can set the minimum Hamming distance in the second argument, an
|
|
84
80
|
|
85
81
|
Currently, the maximum Hamming distance between two duplicate images is set at 15. As per [mperham's explanation](http://www.mikeperham.com/2010/05/21/detecting-duplicate-images-with-phashion/):
|
86
82
|
|
87
|
-
> A “perceptual hash”
|
83
|
+
> A “perceptual hash”is a 64-bit value based on the discrete cosine transform of the image’s frequency spectrum data. Similar images will have hashes that are close in terms of Hamming distance. That is, a binary hash value of 1000 is closer to 0000 than 0011 because it only has one bit different whereas the latter value has two bits different. The duplicate threshold defines how many bits must be different between two hashes for the two associated images to be considered different images. Our testing showed that 15 bits is a good value to start with, it detected all duplicates with a minimum of false positives.
|
88
84
|
|
89
85
|
As a reference point, here are the Hamming distances in these test comparisons using [/test/jpg/Broccoli_Super_Food.jpg](https://github.com/westonplatter/phashion/blob/master/test/jpg/Broccoli_Super_Food.jpg) as the source image:
|
90
86
|
|
@@ -118,12 +114,12 @@ detection of alpha PNG file types.
|
|
118
114
|
Testing
|
119
115
|
-------
|
120
116
|
|
121
|
-
|
122
117
|
#### To run the test suite:
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
rake
|
118
|
+
|
119
|
+
$ cd phashion
|
120
|
+
$ bundle install
|
121
|
+
$ rake compile
|
122
|
+
$ rake test
|
127
123
|
|
128
124
|
|
129
125
|
Author
|
data/lib/phashion.rb
CHANGED
data/lib/phashion/version.rb
CHANGED
data/test/test_phashion.rb
CHANGED
@@ -1,8 +1,29 @@
|
|
1
1
|
require 'helper'
|
2
2
|
require 'sqlite3'
|
3
|
+
require 'tempfile'
|
3
4
|
|
4
5
|
class TestPhashion < Minitest::Test
|
5
6
|
|
7
|
+
def test_text_hash
|
8
|
+
matches = Tempfile.open('foo') do |f|
|
9
|
+
100.times { |i|
|
10
|
+
f.write "hello world #{i}"
|
11
|
+
}
|
12
|
+
f.close
|
13
|
+
a = Phashion.texthash_for f.path
|
14
|
+
b = Phashion.texthash_for f.path
|
15
|
+
|
16
|
+
assert_operator a.length, :>, 0
|
17
|
+
assert_operator b.length, :>, 0
|
18
|
+
a.each { |hash| assert_instance_of Phashion::TextHashPoint, hash }
|
19
|
+
b.each { |hash| assert_instance_of Phashion::TextHashPoint, hash }
|
20
|
+
|
21
|
+
Phashion.textmatches_for(a, b)
|
22
|
+
end
|
23
|
+
assert_operator matches.length, :>, 0
|
24
|
+
matches.each { |match| assert_instance_of Phashion::TextMatch, match }
|
25
|
+
end
|
26
|
+
|
6
27
|
def split(hash)
|
7
28
|
r = hash & 0xFFFFFFFF
|
8
29
|
l = (hash >> 32) & 0xFFFFFFFF
|
metadata
CHANGED
@@ -1,55 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phashion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Perham
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.7.0
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.7.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: sqlite3
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: minitest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 5.2.2
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 5.2.2
|
55
55
|
description: Simple wrapper around the pHash library
|
@@ -60,8 +60,9 @@ extensions:
|
|
60
60
|
- ext/phashion_ext/extconf.rb
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
|
-
- .document
|
64
|
-
- .gitignore
|
63
|
+
- ".document"
|
64
|
+
- ".gitignore"
|
65
|
+
- ".travis.yml"
|
65
66
|
- CHANGES.md
|
66
67
|
- Gemfile
|
67
68
|
- LICENSE
|
@@ -99,17 +100,17 @@ licenses: []
|
|
99
100
|
metadata: {}
|
100
101
|
post_install_message:
|
101
102
|
rdoc_options:
|
102
|
-
- --charset=UTF-8
|
103
|
+
- "--charset=UTF-8"
|
103
104
|
require_paths:
|
104
105
|
- lib
|
105
106
|
required_ruby_version: !ruby/object:Gem::Requirement
|
106
107
|
requirements:
|
107
|
-
- -
|
108
|
+
- - ">="
|
108
109
|
- !ruby/object:Gem::Version
|
109
110
|
version: '0'
|
110
111
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
112
|
requirements:
|
112
|
-
- -
|
113
|
+
- - ">="
|
113
114
|
- !ruby/object:Gem::Version
|
114
115
|
version: '0'
|
115
116
|
requirements: []
|
@@ -140,3 +141,4 @@ test_files:
|
|
140
141
|
- test/png/grass.png
|
141
142
|
- test/png/linux.png
|
142
143
|
- test/test_phashion.rb
|
144
|
+
has_rdoc:
|