perceptual-hash 0.1.1.0 → 0.1.1.1
raw patch · 4 files changed
+68/−12 lines, 4 filesdep +hspecdep ~basePVP ok
version bump matches the API change (PVP)
Dependencies added: hspec
Dependency ranges changed: base
API changes (from Hackage documentation)
Files
- CHANGELOG.md +5/−0
- perceptual-hash.cabal +38/−5
- src/PerceptualHash.hs +7/−7
- test/Spec.hs +18/−0
CHANGELOG.md view
@@ -1,5 +1,10 @@ # phash +## 0.1.1.1++ * Use mirror for convolutions+ * Add `llvm` cabal flag+ ## 0.1.1.0 * Add `with-phash` flag to enable `ForeignHash` module and benchmarks
perceptual-hash.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.0 name: perceptual-hash-version: 0.1.1.0+version: 0.1.1.1 license: BSD3 license-file: LICENSE copyright: Copyright: (c) 2019 Vanessa McHale@@ -22,6 +22,12 @@ description: Use FFI bindings to pHash +flag llvm+ description:+ Use LLVM backend to GHC rather than NCG+ default: False+ manual: True+ library exposed-modules: PerceptualHash@@ -29,7 +35,7 @@ other-modules: Median default-language: Haskell2010- other-extensions: FlexibleContexts+ other-extensions: FlexibleContexts TypeFamilies ghc-options: -Wall -O2 build-depends: base >=4.3 && <5,@@ -39,7 +45,13 @@ primitive -any, repa -any + if flag(llvm)+ ghc-options: -fllvm+ if flag(with-phash)+ pkgconfig-depends: pHash -any++ if flag(with-phash) exposed-modules: ForeignHash @@ -70,6 +82,9 @@ par-traverse >=0.2.0.0, stm >=2.3 + if flag(llvm)+ ghc-options: -fllvm+ if impl(ghc >=8.0) ghc-options: -Wincomplete-uni-patterns -Wincomplete-record-updates -Wredundant-constraints -Widentities@@ -77,10 +92,28 @@ if impl(ghc >=8.4) ghc-options: -Wmissing-export-lists +test-suite perceptual-hash-test+ type: exitcode-stdio-1.0+ main-is: Spec.hs+ hs-source-dirs: test+ default-language: Haskell2010+ ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N+ build-depends:+ base -any,+ perceptual-hash -any,+ hspec -any++ if impl(ghc >=8.0)+ ghc-options: -Wincomplete-uni-patterns -Wincomplete-record-updates+ -Wredundant-constraints -Widentities++ if impl(ghc >=8.4)+ ghc-options: -Wmissing-export-lists+ benchmark phash-bench type: exitcode-stdio-1.0 main-is: Bench.hs- build-tools: cpphs -any+ build-tool-depends: cpphs:cpphs -any hs-source-dirs: bench default-language: Haskell2010 ghc-options: -threaded -rtsopts "-with-rtsopts=-N -qg" -Wall@@ -91,8 +124,8 @@ perceptual-hash -any, criterion -any - if flag(with-phash)- pkgconfig-depends: pHash -any+ if flag(llvm)+ ghc-options: -fllvm if flag(with-phash) cpp-options: -DFOREIGN_PHASH
src/PerceptualHash.hs view
@@ -10,11 +10,11 @@ import Data.Bits (shiftL, (.|.)) import qualified Data.Vector.Unboxed as V import Data.Word (Word64)-import Graphics.Image (Array, Bilinear (..), Border (Edge),- Image, Pixel (PixelX, PixelY),- RSU (..), X, Y, convolve, crop,- makeImage, readImageY, resize,- transpose, (|*|))+import Graphics.Image (Array, Bilinear (..),+ Border (Edge, Reflect), Image,+ Pixel (PixelX, PixelY), RSU (..), X,+ Y, convolve, crop, makeImage,+ readImageY, resize, transpose, (|*|)) import Graphics.Image.Interface (Elevator, toVector) import Median (median) @@ -29,8 +29,8 @@ {-# INLINE meanFilter #-} meanFilter :: (Fractional e, Array arr X e, Array arr cs e) => Image arr cs e -> Image arr cs e-meanFilter = convolve Edge idMat-{-# SCC meanFilter #-}+meanFilter = convolve Reflect idMat+-- {-# SCC meanFilter #-} {-# INLINE size32 #-} size32 :: Array arr cs e => Image arr cs e -> Image arr cs e
+ test/Spec.hs view
@@ -0,0 +1,18 @@+-- vim: syntax=hspec++import PerceptualHash (fileHash)+import Test.Hspec++main :: IO ()+main = hspec $+ describe "fileHash" $ do++ parallel $ it "should match when same" $ do+ actual <- fileHash "demo-data/frog.jpeg"+ expected <- fileHash "demo-data/frog.png"+ actual `shouldBe` expected++ parallel $ it "should not match when different" $ do+ actual <- fileHash "demo-data/cat.png"+ expected <- fileHash "demo-data/frog.png"+ actual `shouldSatisfy` (/= expected)