packages feed

perceptual-hash 0.1.3.0 → 0.1.3.1

raw patch · 5 files changed

+78/−16 lines, 5 files

Files

CHANGELOG.md view
@@ -1,5 +1,9 @@ # phash +## 0.1.3.1++  * Add `include/hs_phash.h` header+ ## 0.1.3.0    * CLI tool now supports several more image formats
README.md view
@@ -6,9 +6,11 @@ [![Hackage](https://img.shields.io/hackage/v/perceptual-hash.svg)](http://hackage.haskell.org/package/perceptual-hash) [![Dependencies of latest version on Hackage](https://img.shields.io/hackage-deps/v/perceptual-hash.svg)](https://hackage.haskell.org/package/perceptual-hash) -This is a command-line tool to detect (potential) duplicate images. It also-contains a Haskell [library](http://hackage.haskell.org/package/perceptual-hash).+This is a Haskell [library](http://hackage.haskell.org/package/perceptual-hash)+to detect (potential) duplicate images. +It also contains a command-line tool.+ ## Use  Use it on one or more directories:@@ -41,3 +43,55 @@ ``` cabal install perceptual-hash -w ghc-8.6.5 ```++## Library++You can find library documentation on+[Hackage](https://hackage.haskell.org/package/perceptual-hash).++### Performance++This library is more performant than the pHash library for PNG+images.++```+benchmarking fileHash/cat.png+time                 21.42 ms   (21.20 ms .. 21.63 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)++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)++benchmarking fileHash/frog.png+time                 12.39 ms   (12.35 ms .. 12.46 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)++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)++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)++benchmarking foreignHash/frog.png+time                 14.03 ms   (13.94 ms .. 14.13 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)+```++### Foreign Library++This package contains a foreign library and header files.
+ include/hs_phash.h view
@@ -0,0 +1,1 @@+uint64_t hs_phash(const char *);
perceptual-hash.cabal view
@@ -1,20 +1,21 @@-cabal-version:   2.0-name:            perceptual-hash-version:         0.1.3.0-license:         BSD3-license-file:    LICENSE-copyright:       Copyright: (c) 2019 Vanessa McHale-maintainer:      vamchale@gmail.com-author:          Vanessa McHale-synopsis:        Find duplicate images-description:     Find similar images using perceptual hashes-category:        Application, CommandLine, Images-build-type:      Simple+cabal-version:      2.0+name:               perceptual-hash+version:            0.1.3.1+license:            BSD3+license-file:       LICENSE+copyright:          Copyright: (c) 2019 Vanessa McHale+maintainer:         vamchale@gmail.com+author:             Vanessa McHale+synopsis:           Find duplicate images+description:        Find similar images using perceptual hashes+category:           Application, CommandLine, Images+build-type:         Simple data-files:     demo-data/cat.png     demo-data/frog.jpeg     demo-data/frog.png +extra-source-files: include/hs_phash.h extra-doc-files:     README.md     CHANGELOG.md@@ -70,6 +71,7 @@     hs-source-dirs:   foreign-src     other-modules:    Export     default-language: Haskell2010+    install-includes: include/hs_phash.h     ghc-options:      -Wall     build-depends:         base -any,
src/ForeignHash.hs view
@@ -1,9 +1,10 @@ -- N.B. this is a good deal faster than the Haskell code module ForeignHash ( foreignFileHash ) where +import           Data.Coerce           (coerce) import           Data.Word             (Word64) import           Foreign.C.String      (CString, withCString)-import           Foreign.C.Types       (CInt (..), CULLong)+import           Foreign.C.Types       (CInt (..), CULLong (..)) import           Foreign.Marshal.Alloc (alloca) import           Foreign.Ptr           (Ptr) import           Foreign.Storable      (peek)@@ -16,7 +17,7 @@     alloca $ \hashPtr -> do         res <- ph_dct_imagehash cstr hashPtr         check res-        fromIntegral <$> peek hashPtr+        coerce <$> peek hashPtr      where check (-1) = error ("Hash of file " ++ fp ++ " failed.")           check 0    = pure ()