Copyright | (c) Laurent P René de Cotret 2019 |
---|---|
License | BSD3 |
Maintainer | laurent.decotret@outlook.com |
Stability | unstable |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
This module defines a Hakyll compiler, compressJpgCompiler
, which can be used to
re-encode Jpeg images at a lower quality during website compilation. Original images are
left unchanged, but compressed images can be up to 10x smaller.
The compressJpgCompiler
is expected to be used like this:
import Hakyll import Hakyll.Images ( loadImage , compressJpgCompiler ) hakyll $ do -- Compress all source Jpegs to a Jpeg quality of 50 match "images/**.jpg" $ do route idRoute compile $ loadImage >>= compressJpgCompiler 50 (... omitted ...)
Synopsis
- type JpgQuality = Int
- compressJpgCompiler :: JpgQuality -> Item Image -> Compiler (Item Image)
- compressJpg :: JpgQuality -> Image -> Image
Documentation
type JpgQuality = Int Source #
Jpeg encoding quality, from 0 (lower quality) to 100 (best quality).
compressJpgCompiler :: JpgQuality -> Item Image -> Compiler (Item Image) Source #
Compiler that compresses a JPG image to a certain quality setting. The quality should be between 0 (lowest quality) and 100 (best quality). An error is raised if the image cannot be decoded.
match "*.jpg" $ do route idRoute compile $ loadImage >>= compressJpgCompiler 50
compressJpg :: JpgQuality -> Image -> Image Source #
Compress a JPG bytestring to a certain quality setting. The quality should be between 0 (lowest quality) and 100 (best quality). An error is raised if the image cannot be decoded, or if the encoding quality is out-of-bounds