perceptual-hash 0.1.3.2 → 0.1.3.3
raw patch · 8 files changed
+51/−30 lines, 8 filesdep −repabinary-addedPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies removed: repa
API changes (from Hackage documentation)
- ForeignHash: foreignFileHash :: FilePath -> IO Word64
Files
- CHANGELOG.md +4/−0
- README.md +33/−24
- demo-data/meme-watermark.jpg binary
- demo-data/meme.png binary
- perceptual-hash.cabal +5/−4
- src/ForeignHash.hs +3/−1
- src/PerceptualHash.hs +1/−1
- test/Spec.hs +5/−0
CHANGELOG.md view
@@ -1,5 +1,9 @@ # phash +## 0.1.3.3++ * Fix bug+ ## 0.1.3.2 * Fix `include/hs_phash.h` installation
README.md view
@@ -11,6 +11,15 @@ It also contains a command-line tool. +- [Use](#use)+- [Installation](#installation)+ - [Script](#script)+ - [Pre-Built Release](#pre-built-release)+ - [Source](#source)+- [Library](#library)+ - [Performance](#performance)+ - [Foreign Library](#foreign-library)+ ## Use Use it on one or more directories:@@ -24,7 +33,7 @@ ### Script -On many platforms, you can install with a script, viz.+On many platforms, you can install the command-line tool with a script: ``` curl -sSl https://raw.githubusercontent.com/vmchale/phash/master/bash/install.sh | sh -s@@ -41,7 +50,7 @@ [GHC](https://www.haskell.org/ghc/download.html). Then: ```-cabal install perceptual-hash -w ghc-8.6.5+cabal install perceptual-hash --constraint='hip +disable-chart' ``` ## Library@@ -51,45 +60,45 @@ ### Performance -This library is more performant than the pHash library for PNG+This library has similar performance to the pHash library for PNG images. ``` benchmarking fileHash/cat.png-time 21.42 ms (21.20 ms .. 21.63 ms)+time 20.67 ms (20.60 ms .. 20.78 ms) 1.000 R² (0.999 R² .. 1.000 R²)-mean 21.34 ms (21.28 ms .. 21.44 ms)-std dev 184.3 μs (93.40 μs .. 266.3 μs)+mean 20.84 ms (20.76 ms .. 21.01 ms)+std dev 246.3 μs (149.5 μs .. 396.7 μs) benchmarking fileHash/frog.jpeg-time 18.16 ms (18.07 ms .. 18.24 ms)- 1.000 R² (1.000 R² .. 1.000 R²)-mean 18.24 ms (18.12 ms .. 18.31 ms)-std dev 230.1 μs (161.3 μs .. 360.2 μs)+time 17.82 ms (17.62 ms .. 18.05 ms)+ 0.999 R² (0.999 R² .. 1.000 R²)+mean 17.54 ms (17.45 ms .. 17.65 ms)+std dev 272.3 μs (194.9 μs .. 369.3 μs) benchmarking fileHash/frog.png-time 12.39 ms (12.35 ms .. 12.46 ms)+time 12.02 ms (11.95 ms .. 12.11 ms) 1.000 R² (0.999 R² .. 1.000 R²)-mean 12.38 ms (12.34 ms .. 12.43 ms)-std dev 114.0 μs (73.36 μs .. 156.5 μs)+mean 12.08 ms (12.04 ms .. 12.13 ms)+std dev 115.0 μs (90.79 μs .. 144.7 μs) benchmarking foreignHash/cat.png-time 27.21 ms (27.09 ms .. 27.47 ms)- 1.000 R² (0.999 R² .. 1.000 R²)-mean 27.24 ms (27.18 ms .. 27.37 ms)-std dev 207.9 μs (84.97 μs .. 311.8 μs)+time 18.86 ms (18.79 ms .. 18.97 ms)+ 1.000 R² (1.000 R² .. 1.000 R²)+mean 18.92 ms (18.87 ms .. 18.99 ms)+std dev 149.7 μs (129.0 μs .. 183.6 μs) benchmarking foreignHash/frog.jpeg-time 12.81 ms (12.78 ms .. 12.84 ms)- 1.000 R² (1.000 R² .. 1.000 R²)-mean 12.87 ms (12.85 ms .. 12.92 ms)-std dev 80.81 μs (56.17 μs .. 113.1 μs)+time 8.533 ms (8.480 ms .. 8.574 ms)+ 1.000 R² (0.999 R² .. 1.000 R²)+mean 8.686 ms (8.644 ms .. 8.745 ms)+std dev 129.0 μs (97.99 μs .. 164.8 μs) benchmarking foreignHash/frog.png-time 14.03 ms (13.94 ms .. 14.13 ms)+time 9.697 ms (9.649 ms .. 9.735 ms) 1.000 R² (1.000 R² .. 1.000 R²)-mean 13.95 ms (13.93 ms .. 13.99 ms)-std dev 79.36 μs (52.02 μs .. 119.5 μs)+mean 9.746 ms (9.717 ms .. 9.775 ms)+std dev 84.08 μs (70.14 μs .. 97.91 μs) ``` ### Foreign Library
+ demo-data/meme-watermark.jpg view
binary file changed (absent → 70181 bytes)
+ demo-data/meme.png view
binary file changed (absent → 548663 bytes)
perceptual-hash.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.0 name: perceptual-hash-version: 0.1.3.2+version: 0.1.3.3 license: BSD3 license-file: LICENSE copyright: Copyright: (c) 2019 Vanessa McHale@@ -14,6 +14,8 @@ demo-data/cat.png demo-data/frog.jpeg demo-data/frog.png+ demo-data/meme.png+ demo-data/meme-watermark.jpg extra-source-files: include/hs_phash.h extra-doc-files:@@ -46,8 +48,7 @@ hip -any, vector-algorithms -any, vector -any,- primitive -any,- repa -any+ primitive -any if flag(llvm) ghc-options: -fllvm@@ -128,7 +129,7 @@ main-is: Spec.hs hs-source-dirs: test default-language: Haskell2010- ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N+ ghc-options: -Wall -threaded -rtsopts "-with-rtsopts=-N -K1K" build-depends: base -any, perceptual-hash -any,
src/ForeignHash.hs view
@@ -1,4 +1,4 @@--- N.B. this is a good deal faster than the Haskell code+-- N.B. this is a little faster than the Haskell code module ForeignHash ( foreignFileHash ) where import Data.Coerce (coerce)@@ -12,6 +12,8 @@ foreign import ccall ph_dct_imagehash :: CString -> Ptr CULLong -> IO CInt -- | Doesn't work with @.gif@ files+--+-- This will throw an exception on failure. foreignFileHash :: FilePath -> IO Word64 foreignFileHash fp = withCString fp $ \cstr -> alloca $ \hashPtr -> do
src/PerceptualHash.hs view
@@ -18,7 +18,7 @@ dct32 :: (Floating e, Array arr Y e) => Image arr Y e dct32 = makeImage (32,32) gen- where gen (i,j) = PixelY $ sqrt(2/n) * cos((fromIntegral ((2*i+1) * j) * pi)/(2*n))+ where gen (i,j) = PixelY $ sqrt(2/n) * cos((fromIntegral ((2*i) * (j-1)) * pi)/(2*n)) n = 32 idMat :: (Fractional e, Array arr X e) => Image arr X e
test/Spec.hs view
@@ -12,6 +12,11 @@ expected <- fileHash "demo-data/frog.png" actual `shouldBe` expected + parallel $ it "should match when same" $ do+ actual <- fileHash "demo-data/meme-watermark.jpg"+ expected <- fileHash "demo-data/meme.png"+ actual `shouldBe` expected+ parallel $ it "should not match when different" $ do actual <- fileHash "demo-data/cat.png" expected <- fileHash "demo-data/frog.png"