hakyll-images 0.4.0 → 0.4.1
raw patch · 7 files changed
+104/−98 lines, 7 files
Files
- CHANGELOG.md +20/−5
- hakyll-images.cabal +2/−2
- library/Hakyll/Images/Common.hs +6/−18
- library/Hakyll/Images/CompressJpg.hs +1/−2
- library/Hakyll/Images/Resize.hs +10/−6
- package.yaml +1/−1
- stack.yaml +64/−64
CHANGELOG.md view
@@ -1,16 +1,31 @@ # Change log -Release 0.1.1+## Release 0.4.1 +* Added some regression tests+* Simplified type architecture (no surface changes)++## Release 0.4++* Fixed an issue from version 0.3.1 where some type instances were missing to write images to disk.++## Release 0.3.1++* Change underlying image type to carry image format around.++## Release 0.3++* Refactored the internal structure to allow for composition of compilers++## Release 0.1.1+ * Exposed `resizeImageCompiler` and `scaleImageCompiler` to the base `Hakyll.Images` module -Release 0.1.0--------------+## Release 0.1.0 * added `resizeImageCompiler` to resize images to a specific shape; * added `scaleImageCompiler` to scale images while keeping aspect ratio. -Release 0.0.1--------------+## Release 0.0.1 * Added compressJpgCompiler to compress JPEGs.
hakyll-images.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 937597bab3f482f7bbc2688e6a13a148528dc5fbd319eceea97fd955b04b54fa+-- hash: 8668d79c72dd31f545171175bf9caadb045ee31f00b196459adfa05a3c45a1b8 name: hakyll-images-version: 0.4.0+version: 0.4.1 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
library/Hakyll/Images/Common.hs view
@@ -12,11 +12,8 @@ Portability : portable -} -module Hakyll.Images.Common ( Image - , Image_(..) +module Hakyll.Images.Common ( Image(..) , ImageFormat(..) - , format - , image , loadImage , encode ) where @@ -44,35 +41,26 @@ | Tiff deriving (Eq, Generic) +-- Automatic derivation of Binary instances requires Generic instance Binary ImageFormat -- Polymorphic type only to get an instance of functor. -- Do not use this type. -data Image_ a = Image ImageFormat a +data Image = Image { format :: ImageFormat + , image :: ByteString + } deriving (Typeable) -instance Functor Image_ where - fmap f (Image fmt a) = Image fmt (f a) - -type Image = Image_ ByteString - -- When writing to disk, we ignore the image format. -- Trusting users to route correctly. instance Writable Image where -- Write the bytestring content write fp item = write fp (image <$> item) +-- Binary instance looks similar to the binary instance for a Hakyll Item instance Binary Image where put (Image fmt content) = put fmt >> put content get = Image <$> get <*> get - --- | Extract format from an image -format :: Image_ a -> ImageFormat -format (Image fmt _) = fmt - --- | Extract data from image -image :: Image_ a -> a -image (Image _ im) = im -- | Load an image from a file. -- This function can be combined with other compilers.
library/Hakyll/Images/CompressJpg.hs view
@@ -45,8 +45,7 @@ import Hakyll.Core.Item (Item(..)) import Hakyll.Core.Compiler (Compiler) -import Hakyll.Images.Common ( Image - , Image_(..) +import Hakyll.Images.Common ( Image(..) , ImageFormat(..) , image , format
library/Hakyll/Images/Resize.hs view
@@ -56,7 +56,7 @@ import Hakyll.Core.Item (Item(..)) import Hakyll.Core.Compiler (Compiler) -import Hakyll.Images.Common (Image, encode, format, image) +import Hakyll.Images.Common (Image(..), encode) type Width = Int type Height = Int @@ -83,14 +83,16 @@ -- compile $ loadImage -- >>= resizeImageCompiler 48 64 -- @ +-- +-- Note that in the resizing process, images will be converted to RGBA8. resizeImageCompiler :: Width -> Height -> Item Image -> Compiler (Item Image) -resizeImageCompiler w h item = do +resizeImageCompiler w h item = let fmt = (format . itemBody) item - return $ (encode fmt . resize w h . decodeImage' . image) <$> item + in return $ (encode fmt . resize w h . decodeImage' . image) <$> item -- | Scale an image to a size that will fit in the specified width and height, -- while preserving aspect ratio. --- +-- -- In the process, an image is converted to RGBA8. Therefore, some information -- loss may occur. scale :: Width -> Height -> DynamicImage -> DynamicImage @@ -113,7 +115,9 @@ -- compile $ loadImage -- >>= scaleImageCompiler 48 64 -- @ +-- +-- Note that in the resizing process, images will be converted to RGBA8. scaleImageCompiler :: Width -> Height -> Item Image -> Compiler (Item Image) -scaleImageCompiler w h item = do +scaleImageCompiler w h item = let fmt = (format . itemBody) item - return $ (encode fmt . scale w h . decodeImage' . image) <$> item+ in return $ (encode fmt . scale w h . decodeImage' . image) <$> item
package.yaml view
@@ -1,5 +1,5 @@ name: hakyll-images -version: '0.4.0' +version: '0.4.1' github: "LaurentRDC/hakyll-images" license: BSD3 author: "Laurent P. René de Cotret"
stack.yaml view
@@ -1,65 +1,65 @@-# 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: lts-12.26--# 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-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: []--# Override default flag values for local packages and extra-deps-# flags: {}--# Extra package databases containing global packages-# extra-package-dbs: []--# 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+# 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: lts-12.26 + +# 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 +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: [] + +# Override default flag values for local packages and extra-deps +# flags: {} + +# Extra package databases containing global packages +# extra-package-dbs: [] + +# 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