packages feed

JuicyPixels-extra 0.1.0 → 0.1.1

raw patch · 5 files changed

+109/−15 lines, 5 filesdep +criteriondep ~JuicyPixelsdep ~JuicyPixels-extradep ~basePVP ok

version bump matches the API change (PVP)

Dependencies added: criterion

Dependency ranges changed: JuicyPixels, JuicyPixels-extra, base

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,3 +1,10 @@+## Juicy Pixels Extra 0.1.1++* Added benchmarks.++* Considerably improved performance of all functions (they are about ×15+  faster now).+ ## Juicy Pixels Extra 0.1.0  * Initial release.
Codec/Picture/Extra.hs view
@@ -93,6 +93,7 @@     y = min (imageHeight - 1) y'     w = min (imageWidth  - x) w'     h = min (imageWidth  - y) h'+{-# INLINEABLE crop #-}  -- | Flip image horizontally. @@ -101,6 +102,7 @@   generateImage gen imageWidth imageHeight   where     gen x = pixelAt img (imageWidth - 1 - x)+{-# INLINEABLE flipHorizontally #-}  -- | Flip image vertically. @@ -109,6 +111,7 @@   generateImage gen imageWidth imageHeight   where     gen x y = pixelAt img x (imageHeight - 1 - y)+{-# INLINEABLE flipVertically #-}  -- | Rotate image to the left by 90°. @@ -117,6 +120,7 @@   generateImage gen imageHeight imageWidth   where     gen x y = pixelAt img y x+{-# INLINEABLE rotateLeft90 #-}  -- | Rotate image to the right by 90°. @@ -125,3 +129,4 @@   generateImage gen imageHeight imageWidth   where     gen x y = pixelAt img y (imageHeight - 1 - x)+{-# INLINEABLE rotateRight90 #-}
JuicyPixels-extra.cabal view
@@ -31,7 +31,7 @@ -- POSSIBILITY OF SUCH DAMAGE.  name:                 JuicyPixels-extra-version:              0.1.0+version:              0.1.1 cabal-version:        >= 1.10 license:              BSD3 license-file:         LICENSE.md@@ -43,16 +43,9 @@ synopsis:             Efficiently scale, crop, flip images with JuicyPixels build-type:           Simple description:          Efficiently scale, crop, flip images with JuicyPixels.-extra-source-files:   CHANGELOG.md+extra-doc-files:      CHANGELOG.md                     , README.md-                    , data-examples/lenna.png-                    , data-examples/lenna-cropped.png-                    , data-examples/lenna-horizontal-flip.png-                    , data-examples/lenna-vertical-flip.png-                    , data-examples/lenna-left-rotated.png-                    , data-examples/lenna-right-rotated.png-                    , data-examples/lenna-scaled-down.png-                    , data-examples/lenna-scaled-up.png+data-files:           data-examples/*.png  source-repository head   type:               git@@ -65,7 +58,7 @@  library   build-depends:      base              >= 4.7 && < 5-                    , JuicyPixels       >= 3.2.6.4+                    , JuicyPixels       >= 3.2.6.4 && < 3.3   exposed-modules:    Codec.Picture.Extra   if flag(dev)     ghc-options:      -Wall -Werror@@ -78,10 +71,24 @@   hs-source-dirs:     tests   type:               exitcode-stdio-1.0   build-depends:      base              >= 4.7 && < 5-                    , JuicyPixels       >= 3.2.6.4-                    , JuicyPixels-extra >= 0.1.0+                    , JuicyPixels       >= 3.2.6.4 && < 3.3+                    , JuicyPixels-extra >= 0.1.1                     , hspec             >= 2.0   other-modules:      Codec.Picture.ExtraSpec+  if flag(dev)+    ghc-options:      -Wall -Werror+  else+    ghc-options:      -O2 -Wall+  default-language:   Haskell2010++benchmark bench+  main-is:            Main.hs+  hs-source-dirs:     bench+  type:               exitcode-stdio-1.0+  build-depends:      base              >= 4.7 && < 5.0+                    , JuicyPixels       >= 3.2.6.4 && < 3.3+                    , JuicyPixels-extra >= 0.1.1+                    , criterion         >= 0.6.2.1 && < 1.2   if flag(dev)     ghc-options:      -Wall -Werror   else
+ bench/Main.hs view
@@ -0,0 +1,75 @@+--+-- Benchmarks for the ‘JuicyPixels-extra’ package.+--+-- Copyright © 2016 Mark Karpov <markkarpov@openmailbox.org>+--+-- Redistribution and use in source and binary forms, with or without+-- modification, are permitted provided that the following conditions are+-- met:+--+-- * Redistributions of source code must retain the above copyright notice,+--   this list of conditions and the following disclaimer.+--+-- * Redistributions in binary form must reproduce the above copyright+--   notice, this list of conditions and the following disclaimer in the+--   documentation and/or other materials provided with the distribution.+--+-- * Neither the name Mark Karpov nor the names of contributors may be used+--   to endorse or promote products derived from this software without+--   specific prior written permission.+--+-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS “AS IS” AND ANY+-- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED+-- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE+-- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY+-- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL+-- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS+-- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)+-- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,+-- STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN+-- ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE+-- POSSIBILITY OF SUCH DAMAGE.++module Main (main) where++import Codec.Picture+import Codec.Picture.Extra+import Criterion.Main++main :: IO ()+main = defaultMain+  [ bgroup "scaleBilinear"+    [ baction "512 × 512"   (scaleBilinear 512 512)   "data-examples/lenna.png"+    , baction "256 × 256"   (scaleBilinear 256 256)   "data-examples/lenna.png"+    , baction "1024 × 1024" (scaleBilinear 1024 1024) "data-examples/lenna.png" ]+  , bgroup "crop"+    [ baction "on 256 horizontally" (crop 256 0 256 512) "data-examples/lenna.png"+    , baction "on 265 vertically"   (crop 0 256 512 256) "data-examples/lenna.png" ]+  , bgroup "flipHorizontally"+    [ baction "512 × 512" flipHorizontally "data-examples/lenna.png"+    , baction "100 × 100" flipHorizontally "data-examples/lenna-scaled-down.png"+    ]+  , bgroup "flipVertically"+    [ baction "512 × 512" flipVertically "data-examples/lenna.png"+    , baction "100 × 100" flipVertically "data-examples/lenna-scaled-down.png" ]+  , bgroup "rotateLeft90"+    [ baction "512 × 512" rotateLeft90 "data-examples/lenna.png"+    , baction "100 × 100" rotateLeft90 "data-examples/lenna-scaled-down.png" ]+  , bgroup "rotateRight90"+    [ baction "512 × 512" rotateRight90 "data-examples/lenna.png"+    , baction "100 × 100" rotateRight90 "data-examples/lenna-scaled-down.png" ]+  ]++-- | Run a benchmark given function to benchmark and where to get image to+-- pass as an input.++baction+  :: String            -- ^ Name of the benchmark+  -> (Image PixelRGB8 -> Image PixelRGB8) -- ^ Transformation to perform+  -> FilePath          -- ^ Where to get image to start with+  -> Benchmark+baction name f path = env getImg (bench name . nf f)+  where+    getImg = do+      (Right (ImageRGB8 img)) <- readImage path+      return img
tests/Codec/Picture/ExtraSpec.hs view
@@ -89,8 +89,8 @@   -> Expectation checkWithFiles f opath fpath = do   (Right (ImageRGB8 original)) <- readImage opath-  (Right (ImageRGB8 flipped))  <- readImage fpath-  f original `blindlySatisfy` sameImage flipped+  (Right (ImageRGB8 result))   <- readImage fpath+  f original `blindlySatisfy` sameImage result  -- | The same as 'shouldSatisfy', but doesn't care if its argument is -- instance of 'Show' or not.