hakyll-images 1.0.1 → 1.1.0
raw patch · 7 files changed
+76/−92 lines, 7 filesdep ~hakyllbinary-addedPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: hakyll
API changes (from Hackage documentation)
Files
- CHANGELOG.md +5/−0
- README.md +1/−1
- hakyll-images.cabal +19/−18
- library/Hakyll/Images/Common.hs +3/−0
- stack.yaml +25/−70
- tests/Hakyll/Images/Resize/Tests.hs +23/−3
- tests/data/donkey.gif binary
CHANGELOG.md view
@@ -1,5 +1,10 @@ # Change log +## Release 1.1.0 + +* Added support for GIFs (#9). +* Releases are now automatically uploaded via Github Actions + ## Release 1.0.1 * The module `Hakyll.Images.Metadata` is now exposed (#5).
README.md view
@@ -1,6 +1,6 @@ # hakyll-images -[](http://hackage.haskell.org/package/hakyll-images) [](https://ci.appveyor.com/project/LaurentRDC/hakyll-images) +[](http://hackage.haskell.org/package/hakyll-images) ## A Haskell package containing utilities to deal with images in the context of Hakyll
hakyll-images.cabal view
@@ -1,7 +1,7 @@ cabal-version: 2.2 name: hakyll-images -version: 1.0.1 +version: 1.1.0 synopsis: Hakyll utilities to work with images description: hakyll-images is an add-on to the hakyll package. It adds utilities to work with images, including JPEG compression. category: Web @@ -19,6 +19,7 @@ stack.yaml data-files: tests/data/piccolo.jpg + tests/data/donkey.gif source-repository head type: git @@ -39,12 +40,12 @@ library ghc-options: -Wall -Wcompat build-depends: - JuicyPixels >=3 && <4 - , JuicyPixels-extra >0.3 && <1 - , base >=4.8 && <5 - , binary >=0.5 && <1 - , bytestring >=0.9 && <1 - , hakyll >4 + JuicyPixels >= 3 && <4 + , JuicyPixels-extra > 0.3 && <1 + , base >= 4.8 && <5 + , binary >= 0.5 && <1 + , bytestring >= 0.9 && <1 + , hakyll > 4 && <5 default-language: Haskell2010 test-suite spec @@ -66,16 +67,16 @@ library ghc-options: -Wall -Wcompat build-depends: - HUnit-approx >=1 && <2 - , JuicyPixels >=3 && <4 - , JuicyPixels-extra >0.3 && <1 - , base >=4.8 && <5 - , binary >=0.5 && <1 - , bytestring >=0.9 && <1 - , directory >=1 && <2 - , filepath >=1 && <2 - , hakyll >4 + HUnit-approx >= 1 && <2 + , JuicyPixels >= 3 && <4 + , JuicyPixels-extra > 0.3 && <1 + , base >= 4.8 && <5 + , binary >= 0.5 && <1 + , bytestring >= 0.9 && <1 + , directory >= 1 && <2 + , filepath >= 1 && <2 + , hakyll > 4 && <5 , hakyll-images - , tasty >=0.11 && <2 - , tasty-hunit >=0.9 && <1 + , tasty >= 0.11 && <2 + , tasty-hunit >= 0.9 && <1 default-language: Haskell2010
library/Hakyll/Images/Common.hs view
@@ -38,6 +38,7 @@ | Png | Bitmap | Tiff + | Gif deriving (Eq, Generic) -- Automatic derivation of Binary instances requires Generic @@ -89,6 +90,7 @@ fromExt' ".bmp" = Bitmap fromExt' ".tif" = Tiff fromExt' ".tiff" = Tiff + fromExt' ".gif" = Gif fromExt' ext' = error $ "Unsupported format: " <> ext' -- Encode images based on file extension @@ -97,3 +99,4 @@ encode Png im = Image Png $ (toStrict . imageToPng) im encode Bitmap im = Image Bitmap $ (toStrict . imageToBitmap) im encode Tiff im = Image Tiff $ (toStrict . imageToTiff) im +encode Gif im = Image Gif $ (toStrict . either (const $ error "Could not parse gif") id . imageToGif) im
stack.yaml view
@@ -1,78 +1,33 @@-# This file was automatically generated by 'stack init' -# -# Some commonly used options have been documented as comments in this file. -# For advanced use and comprehensive documentation of the format, please see: -# https://docs.haskellstack.org/en/stable/yaml_configuration/ - -# Resolver to choose a 'specific' stackage snapshot or a compiler version. -# A snapshot resolver dictates the compiler version and the set of packages -# to be used for project dependencies. For example: -# -# resolver: lts-3.5 -# resolver: nightly-2015-09-21 -# resolver: ghc-7.10.2 -# resolver: ghcjs-0.1.0_ghc-7.10.2 -# -# The location of a snapshot can be provided as a file or url. Stack assumes -# a snapshot provided as a file might change, whereas a url resource does not. -# -# resolver: ./custom-snapshot.yaml -# resolver: https://example.com/snapshots/2018-01-01.yaml -resolver: nightly-2020-10-11 # GHC 8.10.2 - -# GHC 8.10.2 is broken on Windows: -# https://gitlab.haskell.org/ghc/ghc/-/issues/18550 -compiler: ghc-8.10.1 - -allow-newer: true - -# User packages to be built. -# Various formats can be used as shown in the example below. -# -# packages: -# - some-directory -# - https://example.com/foo/bar/baz-0.0.2.tar.gz -# - location: -# git: https://github.com/commercialhaskell/stack.git -# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a -# - location: https://github.com/commercialhaskell/stack/commit/e7b331f14bcffb8367cd58fbfc8b40ec7642100a -# subdirs: -# - auto-update -# - wai +resolver: lts-17.9 # GHC 8.10.3 +compiler: ghc-9.0.1 packages: - . + + # Dependency packages to be pulled from upstream that are not in the resolver # using the same syntax as the packages field. # (e.g., acme-missiles-0.3) extra-deps: -- hakyll-4.13.4.1@sha256:199fa0f7e6e98a1a1858852f8f6a3be2e0f1e4becbe6b9a64db47dac0740ddf2,8867 -- pandoc-2.11.2 -- citeproc-0.2@sha256:72a6b976a1d3ff2107043cfeb942e278ce2b93f0e31752da86bc6431b862ae19,5431 -- commonmark-0.1.1.2@sha256:c06ab05f0f224ab7982502a96e17952823a9b6dae8505fb35194b0baa9e2a975,3278 -- commonmark-extensions-0.2.0.4@sha256:6a437bcfa3c757af4262b71336513619990eafb5cfdc33e57a499c93ad225608,3184 -- commonmark-pandoc-0.2.0.1@sha256:529c6e2c6cabf61558b66a28123eafc1d90d3324be29819f59f024e430312c1f,1105 -- pandoc-citeproc-0.17.0.2@sha256:39c5c60a5eca2c1cb50ae9a00dc7093ca1baac78ad5be4e222505de257dce456,8737 - -# Override default flag values for local packages and extra-deps -# flags: {} +- git: https://github.com/jaspervdj/hakyll.git + commit: 591fbe693d87b84c73b1839acdd424cbc12da3b3 -# Extra package databases containing global packages -# extra-package-dbs: [] +- parsec-3.1.14.0@sha256:72d5c57e6e126adaa781ab97b19dc76f68490c0a3d88f14038219994cabe94e1,4356 +# For GHC 9+ +- text-1.2.4.1 +- directory-1.3.6.2@sha256:6e5f3e0adfe94483d5754d97d741b7d23a5e085d47176075b1955d4fa78f37aa,2811 +- process-1.6.11.0@sha256:d69428130705782d1b61ec8eab2f1d899fd5722ed804c44e104d798dce43e9fb,2819 +- time-1.11.1.2@sha256:a957467595420495c2dd440d9efa1f58c62277cf9438c7e7a515d7a4c65571ec,6287 +- unix-2.7.2.2@sha256:ddb8fc5d5eede81dfad7846eceb65267fe4cf8b4f324bc74542f694a32335ef2,3496 +- template-haskell-2.17.0.0 +- basement-0.0.12 +- memory-0.16.0 +- file-embed-0.0.14.0 +- cryptonite-0.29 +- network-uri-2.6.4.1 -# Control whether we use the GHC we find on the path -# system-ghc: true -# -# Require a specific version of stack, using version ranges -# require-stack-version: -any # Default -# require-stack-version: ">=1.7" -# -# Override the architecture used by stack, especially useful on Windows -# arch: i386 -# arch: x86_64 -# -# Extra directories used by stack for building -# extra-include-dirs: [/path/to/dir] -# extra-lib-dirs: [/path/to/dir] -# -# Allow a newer minor version of GHC than the snapshot specifies -# compiler-check: newer-minor+# Override default flag values for local packages and extra-deps +flags: + hakyll: + previewserver: false + watchserver: false + usepandoc: false
tests/Hakyll/Images/Resize/Tests.hs view
@@ -25,6 +25,13 @@ Left _ -> error "Could not decode test picture piccolo.jpg" Right im -> return im +testGif :: IO DynamicImage +testGif = do + img <- decodeGif <$> B.readFile "tests/data/donkey.gif" + case img of + Left _ -> error "Could not decode test picture donkey.gif" + Right im -> return im + fromAssertions :: -- | Name String -> @@ -36,8 +43,8 @@ zipWith testCase [printf "[%2d] %s" n name | n <- [1 :: Int ..]] -- Test that the rescaled image is of the appropriate scale -testResize :: Assertion -testResize = do +testResizeJpg :: Assertion +testResizeJpg = do image <- testJpg let scaledImage = resize 48 64 image converted = convertRGBA8 scaledImage @@ -48,6 +55,19 @@ assertEqual "Image width was not resized properly" width 48 assertEqual "Image height was not resized properly" height 64 +-- Test that the rescaled image is of the appropriate scale +testResizeGif :: Assertion +testResizeGif = do + image <- testGif + let scaledImage = resize 48 64 image + converted = convertRGBA8 scaledImage + (width, height) = + ( imageWidth converted, + imageHeight converted + ) + assertEqual "Image width was not resized properly" width 48 + assertEqual "Image height was not resized properly" height 64 + -- Test that the rescaled image fits in the appropriate box testScale :: Assertion testScale = do @@ -102,5 +122,5 @@ [testEnsureFit], fromAssertions "resize" - [testResize] + [testResizeJpg, testResizeGif] ]
+ tests/data/donkey.gif view
binary file changed (absent → 276695 bytes)