JuicyPixels-3.2.8.1: Picture loading/serialization (in png, jpeg, bitmap, gif, tga, tiff and radiance)

Safe Haskell | None
Language | Haskell2010

Codec.Picture.Jpg

Description

Module used for JPEG file loading and writing.

Synopsis

- decodeJpeg :: ByteString -> Either String DynamicImage
- decodeJpegWithMetadata :: ByteString -> Either String (DynamicImage, Metadatas)
- encodeJpegAtQuality :: Word8 -> Image PixelYCbCr8 -> ByteString
- encodeJpegAtQualityWithMetadata :: Word8 -> Metadatas -> Image PixelYCbCr8 -> ByteString
- encodeDirectJpegAtQualityWithMetadata :: forall px. JpgEncodable px => Word8 -> Metadatas -> Image px -> ByteString
- encodeJpeg :: Image PixelYCbCr8 -> ByteString
- class (Pixel px, PixelBaseComponent px ~ Word8) => JpgEncodable px

# Documentation

decodeJpeg :: ByteString -> Either String DynamicImage #

Try to decompress and decode a jpeg file. The colorspace is still YCbCr if you want to perform computation on the luma part. You can convert it to RGB using `convertImage` from the `ColorSpaceConvertible` typeclass.

This function can output the following images:

- `ImageY8`
- `ImageYA8`
- `ImageRGB8`
- `ImageCMYK8`
- `ImageYCbCr8`

decodeJpegWithMetadata :: ByteString -> Either String (DynamicImage, Metadatas) #

Equivalent to `decodeJpeg` but also extracts metadatas.

Extract the following metadatas from the JFIF block:

- `DpiX`
- `DpiY`

Exif metadata are also extracted if present.

encodeJpegAtQuality #

Arguments

:: Word8 | Quality factor
-> Image PixelYCbCr8 | Image to encode
-> ByteString | Encoded JPEG

Function to call to encode an image to jpeg. The quality factor should be between 0 and 100 (100 being the best quality).

encodeJpegAtQualityWithMetadata #

Arguments

:: Word8 | Quality factor
-> Metadatas |
-> Image PixelYCbCr8 | Image to encode
-> ByteString | Encoded JPEG

Equivalent to `encodeJpegAtQuality`, but will store the following metadatas in the file using a JFIF block:

- `DpiX`
- `DpiY`

encodeDirectJpegAtQualityWithMetadata #

Arguments

:: JpgEncodable px |
=> Word8 | Quality factor
-> Metadatas |
-> Image px | Image to encode
-> ByteString | Encoded JPEG

Equivalent to `encodeJpegAtQuality`, but will store the following metadatas in the file using a JFIF block:

- `DpiX`
- `DpiY`

This function also allow to create JPEG files with the following color space:

- Y (`Pixel8`) for greyscale.
- RGB (`PixelRGB8`) with no color downsampling on any plane
- CMYK (`PixelCMYK8`) with no color downsampling on any plane

encodeJpeg :: Image PixelYCbCr8 -> ByteString #

Encode an image in jpeg at a reasonnable quality level. If you want better quality or reduced file size, you should use `encodeJpegAtQuality`

class (Pixel px, PixelBaseComponent px ~ Word8) => JpgEncodable px #

Helper type class describing all JPG-encodable pixel types

Minimal complete definition

componentsOfColorSpace, encodingState, scanSpecificationOfColorSpace

Instances

JpgEncodable PixelCMYK8 # |
Methods additionalBlocks :: Image PixelCMYK8 -> [JpgFrame] componentsOfColorSpace :: Image PixelCMYK8 -> [JpgComponent] encodingState :: Int -> Image PixelCMYK8 -> Vector EncoderState imageHuffmanTables :: Image PixelCMYK8 -> [(JpgHuffmanTableSpec, HuffmanPackedTree)] scanSpecificationOfColorSpace :: Image PixelCMYK8 -> [JpgScanSpecification] quantTableSpec :: Image PixelCMYK8 -> Int -> [JpgQuantTableSpec] maximumSubSamplingOf :: Image PixelCMYK8 -> Int
JpgEncodable PixelYCbCr8 # |
Methods additionalBlocks :: Image PixelYCbCr8 -> [JpgFrame] componentsOfColorSpace :: Image PixelYCbCr8 -> [JpgComponent] encodingState :: Int -> Image PixelYCbCr8 -> Vector EncoderState imageHuffmanTables :: Image PixelYCbCr8 -> [(JpgHuffmanTableSpec, HuffmanPackedTree)] scanSpecificationOfColorSpace :: Image PixelYCbCr8 -> [JpgScanSpecification] quantTableSpec :: Image PixelYCbCr8 -> Int -> [JpgQuantTableSpec] maximumSubSamplingOf :: Image PixelYCbCr8 -> Int
JpgEncodable PixelRGB8 # |
Methods additionalBlocks :: Image PixelRGB8 -> [JpgFrame] componentsOfColorSpace :: Image PixelRGB8 -> [JpgComponent] encodingState :: Int -> Image PixelRGB8 -> Vector EncoderState imageHuffmanTables :: Image PixelRGB8 -> [(JpgHuffmanTableSpec, HuffmanPackedTree)] scanSpecificationOfColorSpace :: Image PixelRGB8 -> [JpgScanSpecification] quantTableSpec :: Image PixelRGB8 -> Int -> [JpgQuantTableSpec] maximumSubSamplingOf :: Image PixelRGB8 -> Int
JpgEncodable Pixel8 # |
Methods additionalBlocks :: Image Pixel8 -> [JpgFrame] componentsOfColorSpace :: Image Pixel8 -> [JpgComponent] encodingState :: Int -> Image Pixel8 -> Vector EncoderState imageHuffmanTables :: Image Pixel8 -> [(JpgHuffmanTableSpec, HuffmanPackedTree)] scanSpecificationOfColorSpace :: Image Pixel8 -> [JpgScanSpecification] quantTableSpec :: Image Pixel8 -> Int -> [JpgQuantTableSpec] maximumSubSamplingOf :: Image Pixel8 -> Int