hakyll-images-1.2.1: Hakyll utilities to work with images
Copyright(c) Laurent P René de Cotret 2019 - present
LicenseBSD3
Maintainerlaurent.decotret@outlook.com
Stabilityunstable
Portabilityportable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Hakyll.Images.CompressJpg

Description

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

Documentation

data JpgQuality Source #

Jpeg encoding quality, from 0 (lower quality) to 100 (best quality). @since 1.2.0

Instances

Instances details
Enum JpgQuality Source # 
Instance details

Defined in Hakyll.Images.CompressJpg

Num JpgQuality Source # 
Instance details

Defined in Hakyll.Images.CompressJpg

Integral JpgQuality Source # 
Instance details

Defined in Hakyll.Images.CompressJpg

Real JpgQuality Source # 
Instance details

Defined in Hakyll.Images.CompressJpg

Eq JpgQuality Source # 
Instance details

Defined in Hakyll.Images.CompressJpg

Ord JpgQuality Source # 
Instance details

Defined in Hakyll.Images.CompressJpg

compressJpgCompiler :: Integral a => a -> 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). Values outside of this range will be normalized to the interval [0, 100]. An error is raised if the image cannot be decoded.

match "*.jpg" $ do
    route idRoute
    compile $ loadImage
        >>= compressJpgCompiler 50

compressJpg :: Integral a => a -> 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.

In the rare case where the JPEG data contains transparency information, it will be dropped.