{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeApplications #-}
module Data.Massiv.Array.IO.Image
( module Data.Massiv.Array.IO.Image.JuicyPixels
, module Data.Massiv.Array.IO.Image.Netpbm
, Encode
, encodeImageM
, imageWriteFormats
, imageWriteAutoFormats
, Decode
, decodeImageM
, imageReadFormats
, imageReadAutoFormats
) where
import qualified Data.ByteString as B (ByteString)
import qualified Data.ByteString.Lazy as BL (ByteString)
import Data.Char (toLower)
import Data.Massiv.Array
import Data.Massiv.Array.IO.Base
import Data.Massiv.Array.IO.Image.JuicyPixels
import Data.Massiv.Array.IO.Image.Netpbm
import Graphics.Pixel.ColorSpace
import Prelude as P
import System.FilePath (takeExtension)
data Encode out where
EncodeAs
:: FileFormat f
=> f
-> (forall m. MonadThrow m =>
f -> out -> m BL.ByteString)
-> Encode out
instance Show (Encode out) where
show :: Encode out -> String
show (EncodeAs f
f forall (m :: * -> *). MonadThrow m => f -> out -> m ByteString
_) = f -> String
forall a. Show a => a -> String
show f
f
instance FileFormat (Encode (Image r cs e)) where
ext :: Encode (Image r cs e) -> String
ext (EncodeAs f
f forall (m :: * -> *).
MonadThrow m =>
f -> Image r cs e -> m ByteString
_) = f -> String
forall f. FileFormat f => f -> String
ext f
f
exts :: Encode (Image r cs e) -> [String]
exts (EncodeAs f
f forall (m :: * -> *).
MonadThrow m =>
f -> Image r cs e -> m ByteString
_) = f -> [String]
forall f. FileFormat f => f -> [String]
exts f
f
instance Writable (Encode (Image r cs e)) (Image r cs e) where
encodeM :: Encode (Image r cs e)
-> WriteOptions (Encode (Image r cs e))
-> Image r cs e
-> m ByteString
encodeM (EncodeAs f
f forall (m :: * -> *).
MonadThrow m =>
f -> Image r cs e -> m ByteString
enc) WriteOptions (Encode (Image r cs e))
_ = f -> Image r cs e -> m ByteString
forall (m :: * -> *).
MonadThrow m =>
f -> Image r cs e -> m ByteString
enc f
f
encodeImageM
:: MonadThrow m
=> [Encode (Image r cs e)]
-> FilePath
-> Image r cs e
-> m BL.ByteString
encodeImageM :: [Encode (Image r cs e)] -> String -> Image r cs e -> m ByteString
encodeImageM [Encode (Image r cs e)]
formats String
path Image r cs e
img = do
let ext' :: String
ext' = (Char -> Char) -> ShowS
forall a b. (a -> b) -> [a] -> [b]
P.map Char -> Char
toLower ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
takeExtension ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String
path
case (Encode (Image r cs e) -> Bool)
-> [Encode (Image r cs e)] -> [Encode (Image r cs e)]
forall a. (a -> Bool) -> [a] -> [a]
P.dropWhile (Bool -> Bool
not (Bool -> Bool)
-> (Encode (Image r cs e) -> Bool) -> Encode (Image r cs e) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Encode (Image r cs e) -> Bool
forall f. FileFormat f => String -> f -> Bool
isFormat String
ext') [Encode (Image r cs e)]
formats of
[] -> EncodeError -> m ByteString
forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM (EncodeError -> m ByteString) -> EncodeError -> m ByteString
forall a b. (a -> b) -> a -> b
$ String -> EncodeError
EncodeError (String -> EncodeError) -> String -> EncodeError
forall a b. (a -> b) -> a -> b
$ String
"File format is not supported: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
ext'
(Encode (Image r cs e)
f:[Encode (Image r cs e)]
_) -> Encode (Image r cs e)
-> WriteOptions (Encode (Image r cs e))
-> Image r cs e
-> m ByteString
forall f arr (m :: * -> *).
(Writable f arr, MonadThrow m) =>
f -> WriteOptions f -> arr -> m ByteString
encodeM Encode (Image r cs e)
f () Image r cs e
img
imageWriteFormats :: (Source r Ix2 (Pixel cs e), ColorModel cs e) => [Encode (Image r cs e)]
imageWriteFormats :: [Encode (Image r cs e)]
imageWriteFormats =
[ BMP
-> (forall (m :: * -> *).
MonadThrow m =>
BMP -> Image r cs e -> m ByteString)
-> Encode (Image r cs e)
forall f out.
FileFormat f =>
f
-> (forall (m :: * -> *). MonadThrow m => f -> out -> m ByteString)
-> Encode out
EncodeAs BMP
BMP (\ BMP
f -> BMP -> BitmapOptions -> Image S cs e -> m ByteString
forall cs e (m :: * -> *).
(ColorModel cs e, MonadThrow m) =>
BMP -> BitmapOptions -> Image S cs e -> m ByteString
encodeBMP BMP
f BitmapOptions
forall a. Default a => a
def (Image S cs e -> m ByteString)
-> (Image r cs e -> Image S cs e) -> Image r cs e -> m ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall ix e r'.
(Mutable S ix e, Source r' ix e) =>
Array r' ix e -> Array S ix e
forall r ix e r'.
(Mutable r ix e, Source r' ix e) =>
Array r' ix e -> Array r ix e
computeSource @S)
, GIF
-> (forall (m :: * -> *).
MonadThrow m =>
GIF -> Image r cs e -> m ByteString)
-> Encode (Image r cs e)
forall f out.
FileFormat f =>
f
-> (forall (m :: * -> *). MonadThrow m => f -> out -> m ByteString)
-> Encode out
EncodeAs GIF
GIF (\ GIF
f -> GIF -> GifOptions -> Image S cs e -> m ByteString
forall cs e (m :: * -> *).
(ColorModel cs e, MonadThrow m) =>
GIF -> GifOptions -> Image S cs e -> m ByteString
encodeGIF GIF
f GifOptions
forall a. Default a => a
def (Image S cs e -> m ByteString)
-> (Image r cs e -> Image S cs e) -> Image r cs e -> m ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall ix e r'.
(Mutable S ix e, Source r' ix e) =>
Array r' ix e -> Array S ix e
forall r ix e r'.
(Mutable r ix e, Source r' ix e) =>
Array r' ix e -> Array r ix e
computeSource @S)
, HDR
-> (forall (m :: * -> *).
MonadThrow m =>
HDR -> Image r cs e -> m ByteString)
-> Encode (Image r cs e)
forall f out.
FileFormat f =>
f
-> (forall (m :: * -> *). MonadThrow m => f -> out -> m ByteString)
-> Encode out
EncodeAs HDR
HDR (\ HDR
f -> HDR -> HdrOptions -> Image S cs e -> m ByteString
forall cs e (m :: * -> *).
(ColorModel cs e, MonadThrow m) =>
HDR -> HdrOptions -> Image S cs e -> m ByteString
encodeHDR HDR
f HdrOptions
forall a. Default a => a
def (Image S cs e -> m ByteString)
-> (Image r cs e -> Image S cs e) -> Image r cs e -> m ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall ix e r'.
(Mutable S ix e, Source r' ix e) =>
Array r' ix e -> Array S ix e
forall r ix e r'.
(Mutable r ix e, Source r' ix e) =>
Array r' ix e -> Array r ix e
computeSource @S)
, JPG
-> (forall (m :: * -> *).
MonadThrow m =>
JPG -> Image r cs e -> m ByteString)
-> Encode (Image r cs e)
forall f out.
FileFormat f =>
f
-> (forall (m :: * -> *). MonadThrow m => f -> out -> m ByteString)
-> Encode out
EncodeAs JPG
JPG (\ JPG
f -> JPG -> JpegOptions -> Image S cs e -> m ByteString
forall cs e (m :: * -> *).
(ColorModel cs e, MonadThrow m) =>
JPG -> JpegOptions -> Image S cs e -> m ByteString
encodeJPG JPG
f JpegOptions
forall a. Default a => a
def (Image S cs e -> m ByteString)
-> (Image r cs e -> Image S cs e) -> Image r cs e -> m ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall ix e r'.
(Mutable S ix e, Source r' ix e) =>
Array r' ix e -> Array S ix e
forall r ix e r'.
(Mutable r ix e, Source r' ix e) =>
Array r' ix e -> Array r ix e
computeSource @S)
, PNG
-> (forall (m :: * -> *).
MonadThrow m =>
PNG -> Image r cs e -> m ByteString)
-> Encode (Image r cs e)
forall f out.
FileFormat f =>
f
-> (forall (m :: * -> *). MonadThrow m => f -> out -> m ByteString)
-> Encode out
EncodeAs PNG
PNG (\ PNG
f -> PNG -> Image S cs e -> m ByteString
forall cs e (m :: * -> *).
(ColorModel cs e, MonadThrow m) =>
PNG -> Image S cs e -> m ByteString
encodePNG PNG
f (Image S cs e -> m ByteString)
-> (Image r cs e -> Image S cs e) -> Image r cs e -> m ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall ix e r'.
(Mutable S ix e, Source r' ix e) =>
Array r' ix e -> Array S ix e
forall r ix e r'.
(Mutable r ix e, Source r' ix e) =>
Array r' ix e -> Array r ix e
computeSource @S)
, TGA
-> (forall (m :: * -> *).
MonadThrow m =>
TGA -> Image r cs e -> m ByteString)
-> Encode (Image r cs e)
forall f out.
FileFormat f =>
f
-> (forall (m :: * -> *). MonadThrow m => f -> out -> m ByteString)
-> Encode out
EncodeAs TGA
TGA (\ TGA
f -> TGA -> Image S cs e -> m ByteString
forall cs e (m :: * -> *).
(ColorModel cs e, MonadThrow m) =>
TGA -> Image S cs e -> m ByteString
encodeTGA TGA
f (Image S cs e -> m ByteString)
-> (Image r cs e -> Image S cs e) -> Image r cs e -> m ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall ix e r'.
(Mutable S ix e, Source r' ix e) =>
Array r' ix e -> Array S ix e
forall r ix e r'.
(Mutable r ix e, Source r' ix e) =>
Array r' ix e -> Array r ix e
computeSource @S)
, TIF
-> (forall (m :: * -> *).
MonadThrow m =>
TIF -> Image r cs e -> m ByteString)
-> Encode (Image r cs e)
forall f out.
FileFormat f =>
f
-> (forall (m :: * -> *). MonadThrow m => f -> out -> m ByteString)
-> Encode out
EncodeAs TIF
TIF (\ TIF
f -> TIF -> Image S cs e -> m ByteString
forall cs e (m :: * -> *).
(ColorModel cs e, MonadThrow m) =>
TIF -> Image S cs e -> m ByteString
encodeTIF TIF
f (Image S cs e -> m ByteString)
-> (Image r cs e -> Image S cs e) -> Image r cs e -> m ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall ix e r'.
(Mutable S ix e, Source r' ix e) =>
Array r' ix e -> Array S ix e
forall r ix e r'.
(Mutable r ix e, Source r' ix e) =>
Array r' ix e -> Array r ix e
computeSource @S)
]
imageWriteAutoFormats ::
(Source r Ix2 (Pixel cs e), ColorSpace cs i e, ColorSpace (BaseSpace cs) i e)
=> [Encode (Image r cs e)]
imageWriteAutoFormats :: [Encode (Image r cs e)]
imageWriteAutoFormats =
[ Auto BMP
-> (forall (m :: * -> *).
MonadThrow m =>
Auto BMP -> Image r cs e -> m ByteString)
-> Encode (Image r cs e)
forall f out.
FileFormat f =>
f
-> (forall (m :: * -> *). MonadThrow m => f -> out -> m ByteString)
-> Encode out
EncodeAs (BMP -> Auto BMP
forall f. f -> Auto f
Auto BMP
BMP) (\Auto BMP
f -> ByteString -> m ByteString
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ByteString -> m ByteString)
-> (Image r cs e -> ByteString) -> Image r cs e -> m ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Auto BMP -> BitmapOptions -> Image r cs e -> ByteString
forall r cs i e.
(ColorSpace (BaseSpace cs) i e, ColorSpace cs i e,
Source r Ix2 (Pixel cs e)) =>
Auto BMP -> BitmapOptions -> Image r cs e -> ByteString
encodeAutoBMP Auto BMP
f BitmapOptions
forall a. Default a => a
def)
, Auto GIF
-> (forall (m :: * -> *).
MonadThrow m =>
Auto GIF -> Image r cs e -> m ByteString)
-> Encode (Image r cs e)
forall f out.
FileFormat f =>
f
-> (forall (m :: * -> *). MonadThrow m => f -> out -> m ByteString)
-> Encode out
EncodeAs (GIF -> Auto GIF
forall f. f -> Auto f
Auto GIF
GIF) (Auto GIF -> GifOptions -> Image r cs e -> m ByteString
forall r cs i e (m :: * -> *).
(ColorSpace cs i e, Source r Ix2 (Pixel cs e), MonadThrow m) =>
Auto GIF -> GifOptions -> Image r cs e -> m ByteString
`encodeAutoGIF` GifOptions
forall a. Default a => a
def)
, Auto HDR
-> (forall (m :: * -> *).
MonadThrow m =>
Auto HDR -> Image r cs e -> m ByteString)
-> Encode (Image r cs e)
forall f out.
FileFormat f =>
f
-> (forall (m :: * -> *). MonadThrow m => f -> out -> m ByteString)
-> Encode out
EncodeAs (HDR -> Auto HDR
forall f. f -> Auto f
Auto HDR
HDR) (\Auto HDR
f -> ByteString -> m ByteString
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ByteString -> m ByteString)
-> (Image r cs e -> ByteString) -> Image r cs e -> m ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Auto HDR -> HdrOptions -> Image r cs e -> ByteString
forall r cs i e.
(ColorSpace cs i e, Source r Ix2 (Pixel cs e)) =>
Auto HDR -> HdrOptions -> Image r cs e -> ByteString
encodeAutoHDR Auto HDR
f HdrOptions
forall a. Default a => a
def)
, Auto JPG
-> (forall (m :: * -> *).
MonadThrow m =>
Auto JPG -> Image r cs e -> m ByteString)
-> Encode (Image r cs e)
forall f out.
FileFormat f =>
f
-> (forall (m :: * -> *). MonadThrow m => f -> out -> m ByteString)
-> Encode out
EncodeAs (JPG -> Auto JPG
forall f. f -> Auto f
Auto JPG
JPG) (\Auto JPG
f -> ByteString -> m ByteString
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ByteString -> m ByteString)
-> (Image r cs e -> ByteString) -> Image r cs e -> m ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Auto JPG -> JpegOptions -> Image r cs e -> ByteString
forall r cs i e.
(ColorSpace (BaseSpace cs) i e, ColorSpace cs i e,
Source r Ix2 (Pixel cs e)) =>
Auto JPG -> JpegOptions -> Image r cs e -> ByteString
encodeAutoJPG Auto JPG
f JpegOptions
forall a. Default a => a
def)
, Auto PNG
-> (forall (m :: * -> *).
MonadThrow m =>
Auto PNG -> Image r cs e -> m ByteString)
-> Encode (Image r cs e)
forall f out.
FileFormat f =>
f
-> (forall (m :: * -> *). MonadThrow m => f -> out -> m ByteString)
-> Encode out
EncodeAs (PNG -> Auto PNG
forall f. f -> Auto f
Auto PNG
PNG) (\Auto PNG
f -> ByteString -> m ByteString
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ByteString -> m ByteString)
-> (Image r cs e -> ByteString) -> Image r cs e -> m ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Auto PNG -> Image r cs e -> ByteString
forall r cs i e.
(ColorSpace (BaseSpace cs) i e, ColorSpace cs i e,
Source r Ix2 (Pixel cs e)) =>
Auto PNG -> Image r cs e -> ByteString
encodeAutoPNG Auto PNG
f)
, Auto TGA
-> (forall (m :: * -> *).
MonadThrow m =>
Auto TGA -> Image r cs e -> m ByteString)
-> Encode (Image r cs e)
forall f out.
FileFormat f =>
f
-> (forall (m :: * -> *). MonadThrow m => f -> out -> m ByteString)
-> Encode out
EncodeAs (TGA -> Auto TGA
forall f. f -> Auto f
Auto TGA
TGA) (\Auto TGA
f -> ByteString -> m ByteString
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ByteString -> m ByteString)
-> (Image r cs e -> ByteString) -> Image r cs e -> m ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Auto TGA -> Image r cs e -> ByteString
forall r cs i e.
(ColorSpace (BaseSpace cs) i e, ColorSpace cs i e,
Source r Ix2 (Pixel cs e)) =>
Auto TGA -> Image r cs e -> ByteString
encodeAutoTGA Auto TGA
f)
, Auto TIF
-> (forall (m :: * -> *).
MonadThrow m =>
Auto TIF -> Image r cs e -> m ByteString)
-> Encode (Image r cs e)
forall f out.
FileFormat f =>
f
-> (forall (m :: * -> *). MonadThrow m => f -> out -> m ByteString)
-> Encode out
EncodeAs (TIF -> Auto TIF
forall f. f -> Auto f
Auto TIF
TIF) (\Auto TIF
f -> ByteString -> m ByteString
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ByteString -> m ByteString)
-> (Image r cs e -> ByteString) -> Image r cs e -> m ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Auto TIF -> Image r cs e -> ByteString
forall r cs i e.
(ColorSpace (BaseSpace cs) i e, ColorSpace cs i e,
Source r Ix2 (Pixel cs e)) =>
Auto TIF -> Image r cs e -> ByteString
encodeAutoTIF Auto TIF
f)
]
data Decode out where
DecodeAs
:: FileFormat f
=> f
-> (forall m. MonadThrow m => f -> B.ByteString -> m out)
-> Decode out
instance Show (Decode out) where
show :: Decode out -> String
show (DecodeAs f
f forall (m :: * -> *). MonadThrow m => f -> ByteString -> m out
_) = f -> String
forall a. Show a => a -> String
show f
f
instance FileFormat (Decode (Image r cs e)) where
ext :: Decode (Image r cs e) -> String
ext (DecodeAs f
f forall (m :: * -> *).
MonadThrow m =>
f -> ByteString -> m (Image r cs e)
_) = f -> String
forall f. FileFormat f => f -> String
ext f
f
exts :: Decode (Image r cs e) -> [String]
exts (DecodeAs f
f forall (m :: * -> *).
MonadThrow m =>
f -> ByteString -> m (Image r cs e)
_) = f -> [String]
forall f. FileFormat f => f -> [String]
exts f
f
instance Readable (Decode (Image r cs e)) (Image r cs e) where
decodeM :: Decode (Image r cs e) -> ByteString -> m (Image r cs e)
decodeM (DecodeAs f
f forall (m :: * -> *).
MonadThrow m =>
f -> ByteString -> m (Image r cs e)
dec) = f -> ByteString -> m (Image r cs e)
forall (m :: * -> *).
MonadThrow m =>
f -> ByteString -> m (Image r cs e)
dec f
f
decodeImageM
:: MonadThrow m
=> [Decode (Image r cs e)]
-> FilePath
-> B.ByteString
-> m (Image r cs e)
decodeImageM :: [Decode (Image r cs e)] -> String -> ByteString -> m (Image r cs e)
decodeImageM [Decode (Image r cs e)]
formats String
path ByteString
bs = do
let ext' :: String
ext' = (Char -> Char) -> ShowS
forall a b. (a -> b) -> [a] -> [b]
P.map Char -> Char
toLower ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
takeExtension ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$ String
path
case (Decode (Image r cs e) -> Bool)
-> [Decode (Image r cs e)] -> [Decode (Image r cs e)]
forall a. (a -> Bool) -> [a] -> [a]
P.dropWhile (Bool -> Bool
not (Bool -> Bool)
-> (Decode (Image r cs e) -> Bool) -> Decode (Image r cs e) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Decode (Image r cs e) -> Bool
forall f. FileFormat f => String -> f -> Bool
isFormat String
ext') [Decode (Image r cs e)]
formats of
[] -> DecodeError -> m (Image r cs e)
forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM (DecodeError -> m (Image r cs e))
-> DecodeError -> m (Image r cs e)
forall a b. (a -> b) -> a -> b
$ String -> DecodeError
DecodeError (String -> DecodeError) -> String -> DecodeError
forall a b. (a -> b) -> a -> b
$ String
"File format is not supported: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
ext'
(Decode (Image r cs e)
f:[Decode (Image r cs e)]
_) -> Decode (Image r cs e) -> ByteString -> m (Image r cs e)
forall f arr (m :: * -> *).
(Readable f arr, MonadThrow m) =>
f -> ByteString -> m arr
decodeM Decode (Image r cs e)
f ByteString
bs
imageReadFormats :: ColorModel cs e => [Decode (Image S cs e)]
imageReadFormats :: [Decode (Image S cs e)]
imageReadFormats =
[ BMP
-> (forall (m :: * -> *).
MonadThrow m =>
BMP -> ByteString -> m (Image S cs e))
-> Decode (Image S cs e)
forall f out.
FileFormat f =>
f
-> (forall (m :: * -> *). MonadThrow m => f -> ByteString -> m out)
-> Decode out
DecodeAs BMP
BMP forall cs e (m :: * -> *).
(ColorModel cs e, MonadThrow m) =>
BMP -> ByteString -> m (Image S cs e)
forall (m :: * -> *).
MonadThrow m =>
BMP -> ByteString -> m (Image S cs e)
decodeBMP
, GIF
-> (forall (m :: * -> *).
MonadThrow m =>
GIF -> ByteString -> m (Image S cs e))
-> Decode (Image S cs e)
forall f out.
FileFormat f =>
f
-> (forall (m :: * -> *). MonadThrow m => f -> ByteString -> m out)
-> Decode out
DecodeAs GIF
GIF forall cs e (m :: * -> *).
(ColorModel cs e, MonadThrow m) =>
GIF -> ByteString -> m (Image S cs e)
forall (m :: * -> *).
MonadThrow m =>
GIF -> ByteString -> m (Image S cs e)
decodeGIF
, HDR
-> (forall (m :: * -> *).
MonadThrow m =>
HDR -> ByteString -> m (Image S cs e))
-> Decode (Image S cs e)
forall f out.
FileFormat f =>
f
-> (forall (m :: * -> *). MonadThrow m => f -> ByteString -> m out)
-> Decode out
DecodeAs HDR
HDR forall cs e (m :: * -> *).
(ColorModel cs e, MonadThrow m) =>
HDR -> ByteString -> m (Image S cs e)
forall (m :: * -> *).
MonadThrow m =>
HDR -> ByteString -> m (Image S cs e)
decodeHDR
, JPG
-> (forall (m :: * -> *).
MonadThrow m =>
JPG -> ByteString -> m (Image S cs e))
-> Decode (Image S cs e)
forall f out.
FileFormat f =>
f
-> (forall (m :: * -> *). MonadThrow m => f -> ByteString -> m out)
-> Decode out
DecodeAs JPG
JPG forall cs e (m :: * -> *).
(ColorModel cs e, MonadThrow m) =>
JPG -> ByteString -> m (Image S cs e)
forall (m :: * -> *).
MonadThrow m =>
JPG -> ByteString -> m (Image S cs e)
decodeJPG
, PNG
-> (forall (m :: * -> *).
MonadThrow m =>
PNG -> ByteString -> m (Image S cs e))
-> Decode (Image S cs e)
forall f out.
FileFormat f =>
f
-> (forall (m :: * -> *). MonadThrow m => f -> ByteString -> m out)
-> Decode out
DecodeAs PNG
PNG forall cs e (m :: * -> *).
(ColorModel cs e, MonadThrow m) =>
PNG -> ByteString -> m (Image S cs e)
forall (m :: * -> *).
MonadThrow m =>
PNG -> ByteString -> m (Image S cs e)
decodePNG
, TGA
-> (forall (m :: * -> *).
MonadThrow m =>
TGA -> ByteString -> m (Image S cs e))
-> Decode (Image S cs e)
forall f out.
FileFormat f =>
f
-> (forall (m :: * -> *). MonadThrow m => f -> ByteString -> m out)
-> Decode out
DecodeAs TGA
TGA forall cs e (m :: * -> *).
(ColorModel cs e, MonadThrow m) =>
TGA -> ByteString -> m (Image S cs e)
forall (m :: * -> *).
MonadThrow m =>
TGA -> ByteString -> m (Image S cs e)
decodeTGA
, TIF
-> (forall (m :: * -> *).
MonadThrow m =>
TIF -> ByteString -> m (Image S cs e))
-> Decode (Image S cs e)
forall f out.
FileFormat f =>
f
-> (forall (m :: * -> *). MonadThrow m => f -> ByteString -> m out)
-> Decode out
DecodeAs TIF
TIF forall cs e (m :: * -> *).
(ColorModel cs e, MonadThrow m) =>
TIF -> ByteString -> m (Image S cs e)
forall (m :: * -> *).
MonadThrow m =>
TIF -> ByteString -> m (Image S cs e)
decodeTIF
, PBM
-> (forall (m :: * -> *).
MonadThrow m =>
PBM -> ByteString -> m (Image S cs e))
-> Decode (Image S cs e)
forall f out.
FileFormat f =>
f
-> (forall (m :: * -> *). MonadThrow m => f -> ByteString -> m out)
-> Decode out
DecodeAs PBM
PBM (\PBM
f -> ((Image S cs e, Maybe ByteString) -> Image S cs e)
-> m (Image S cs e, Maybe ByteString) -> m (Image S cs e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Image S cs e, Maybe ByteString) -> Image S cs e
forall a b. (a, b) -> a
fst (m (Image S cs e, Maybe ByteString) -> m (Image S cs e))
-> (ByteString -> m (Image S cs e, Maybe ByteString))
-> ByteString
-> m (Image S cs e)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PBM -> ByteString -> m (Image S cs e, Maybe ByteString)
forall f cs e (m :: * -> *).
(FileFormat f, ColorModel cs e, MonadThrow m) =>
f -> ByteString -> m (Image S cs e, Maybe ByteString)
decodeNetpbmImage PBM
f)
, PGM
-> (forall (m :: * -> *).
MonadThrow m =>
PGM -> ByteString -> m (Image S cs e))
-> Decode (Image S cs e)
forall f out.
FileFormat f =>
f
-> (forall (m :: * -> *). MonadThrow m => f -> ByteString -> m out)
-> Decode out
DecodeAs PGM
PGM (\PGM
f -> ((Image S cs e, Maybe ByteString) -> Image S cs e)
-> m (Image S cs e, Maybe ByteString) -> m (Image S cs e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Image S cs e, Maybe ByteString) -> Image S cs e
forall a b. (a, b) -> a
fst (m (Image S cs e, Maybe ByteString) -> m (Image S cs e))
-> (ByteString -> m (Image S cs e, Maybe ByteString))
-> ByteString
-> m (Image S cs e)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PGM -> ByteString -> m (Image S cs e, Maybe ByteString)
forall f cs e (m :: * -> *).
(FileFormat f, ColorModel cs e, MonadThrow m) =>
f -> ByteString -> m (Image S cs e, Maybe ByteString)
decodeNetpbmImage PGM
f)
, PPM
-> (forall (m :: * -> *).
MonadThrow m =>
PPM -> ByteString -> m (Image S cs e))
-> Decode (Image S cs e)
forall f out.
FileFormat f =>
f
-> (forall (m :: * -> *). MonadThrow m => f -> ByteString -> m out)
-> Decode out
DecodeAs PPM
PPM (\PPM
f -> ((Image S cs e, Maybe ByteString) -> Image S cs e)
-> m (Image S cs e, Maybe ByteString) -> m (Image S cs e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Image S cs e, Maybe ByteString) -> Image S cs e
forall a b. (a, b) -> a
fst (m (Image S cs e, Maybe ByteString) -> m (Image S cs e))
-> (ByteString -> m (Image S cs e, Maybe ByteString))
-> ByteString
-> m (Image S cs e)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PPM -> ByteString -> m (Image S cs e, Maybe ByteString)
forall f cs e (m :: * -> *).
(FileFormat f, ColorModel cs e, MonadThrow m) =>
f -> ByteString -> m (Image S cs e, Maybe ByteString)
decodeNetpbmImage PPM
f)
]
imageReadAutoFormats
:: (Mutable r Ix2 (Pixel cs e), ColorSpace cs i e)
=> [Decode (Image r cs e)]
imageReadAutoFormats :: [Decode (Image r cs e)]
imageReadAutoFormats =
[ Auto BMP
-> (forall (m :: * -> *).
MonadThrow m =>
Auto BMP -> ByteString -> m (Image r cs e))
-> Decode (Image r cs e)
forall f out.
FileFormat f =>
f
-> (forall (m :: * -> *). MonadThrow m => f -> ByteString -> m out)
-> Decode out
DecodeAs (BMP -> Auto BMP
forall f. f -> Auto f
Auto BMP
BMP) forall r cs e i (m :: * -> *).
(Mutable r Ix2 (Pixel cs e), ColorSpace cs i e, MonadThrow m) =>
Auto BMP -> ByteString -> m (Image r cs e)
forall (m :: * -> *).
MonadThrow m =>
Auto BMP -> ByteString -> m (Image r cs e)
decodeAutoBMP
, Auto GIF
-> (forall (m :: * -> *).
MonadThrow m =>
Auto GIF -> ByteString -> m (Image r cs e))
-> Decode (Image r cs e)
forall f out.
FileFormat f =>
f
-> (forall (m :: * -> *). MonadThrow m => f -> ByteString -> m out)
-> Decode out
DecodeAs (GIF -> Auto GIF
forall f. f -> Auto f
Auto GIF
GIF) forall r cs e i (m :: * -> *).
(Mutable r Ix2 (Pixel cs e), ColorSpace cs i e, MonadThrow m) =>
Auto GIF -> ByteString -> m (Image r cs e)
forall (m :: * -> *).
MonadThrow m =>
Auto GIF -> ByteString -> m (Image r cs e)
decodeAutoGIF
, Auto HDR
-> (forall (m :: * -> *).
MonadThrow m =>
Auto HDR -> ByteString -> m (Image r cs e))
-> Decode (Image r cs e)
forall f out.
FileFormat f =>
f
-> (forall (m :: * -> *). MonadThrow m => f -> ByteString -> m out)
-> Decode out
DecodeAs (HDR -> Auto HDR
forall f. f -> Auto f
Auto HDR
HDR) forall r cs e i (m :: * -> *).
(Mutable r Ix2 (Pixel cs e), ColorSpace cs i e, MonadThrow m) =>
Auto HDR -> ByteString -> m (Image r cs e)
forall (m :: * -> *).
MonadThrow m =>
Auto HDR -> ByteString -> m (Image r cs e)
decodeAutoHDR
, Auto JPG
-> (forall (m :: * -> *).
MonadThrow m =>
Auto JPG -> ByteString -> m (Image r cs e))
-> Decode (Image r cs e)
forall f out.
FileFormat f =>
f
-> (forall (m :: * -> *). MonadThrow m => f -> ByteString -> m out)
-> Decode out
DecodeAs (JPG -> Auto JPG
forall f. f -> Auto f
Auto JPG
JPG) forall r cs e i (m :: * -> *).
(Mutable r Ix2 (Pixel cs e), ColorSpace cs i e, MonadThrow m) =>
Auto JPG -> ByteString -> m (Image r cs e)
forall (m :: * -> *).
MonadThrow m =>
Auto JPG -> ByteString -> m (Image r cs e)
decodeAutoJPG
, Auto PNG
-> (forall (m :: * -> *).
MonadThrow m =>
Auto PNG -> ByteString -> m (Image r cs e))
-> Decode (Image r cs e)
forall f out.
FileFormat f =>
f
-> (forall (m :: * -> *). MonadThrow m => f -> ByteString -> m out)
-> Decode out
DecodeAs (PNG -> Auto PNG
forall f. f -> Auto f
Auto PNG
PNG) forall r cs e i (m :: * -> *).
(Mutable r Ix2 (Pixel cs e), ColorSpace cs i e, MonadThrow m) =>
Auto PNG -> ByteString -> m (Image r cs e)
forall (m :: * -> *).
MonadThrow m =>
Auto PNG -> ByteString -> m (Image r cs e)
decodeAutoPNG
, Auto TGA
-> (forall (m :: * -> *).
MonadThrow m =>
Auto TGA -> ByteString -> m (Image r cs e))
-> Decode (Image r cs e)
forall f out.
FileFormat f =>
f
-> (forall (m :: * -> *). MonadThrow m => f -> ByteString -> m out)
-> Decode out
DecodeAs (TGA -> Auto TGA
forall f. f -> Auto f
Auto TGA
TGA) forall r cs e i (m :: * -> *).
(Mutable r Ix2 (Pixel cs e), ColorSpace cs i e, MonadThrow m) =>
Auto TGA -> ByteString -> m (Image r cs e)
forall (m :: * -> *).
MonadThrow m =>
Auto TGA -> ByteString -> m (Image r cs e)
decodeAutoTGA
, Auto TIF
-> (forall (m :: * -> *).
MonadThrow m =>
Auto TIF -> ByteString -> m (Image r cs e))
-> Decode (Image r cs e)
forall f out.
FileFormat f =>
f
-> (forall (m :: * -> *). MonadThrow m => f -> ByteString -> m out)
-> Decode out
DecodeAs (TIF -> Auto TIF
forall f. f -> Auto f
Auto TIF
TIF) forall r cs e i (m :: * -> *).
(Mutable r Ix2 (Pixel cs e), ColorSpace cs i e, MonadThrow m) =>
Auto TIF -> ByteString -> m (Image r cs e)
forall (m :: * -> *).
MonadThrow m =>
Auto TIF -> ByteString -> m (Image r cs e)
decodeAutoTIF
, Auto PBM
-> (forall (m :: * -> *).
MonadThrow m =>
Auto PBM -> ByteString -> m (Image r cs e))
-> Decode (Image r cs e)
forall f out.
FileFormat f =>
f
-> (forall (m :: * -> *). MonadThrow m => f -> ByteString -> m out)
-> Decode out
DecodeAs (PBM -> Auto PBM
forall f. f -> Auto f
Auto PBM
PBM) (\Auto PBM
f -> ((Image r cs e, Maybe ByteString) -> Image r cs e)
-> m (Image r cs e, Maybe ByteString) -> m (Image r cs e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Image r cs e, Maybe ByteString) -> Image r cs e
forall a b. (a, b) -> a
fst (m (Image r cs e, Maybe ByteString) -> m (Image r cs e))
-> (ByteString -> m (Image r cs e, Maybe ByteString))
-> ByteString
-> m (Image r cs e)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Auto PBM -> ByteString -> m (Image r cs e, Maybe ByteString)
forall f r cs e (m :: * -> *) i.
(FileFormat f, Mutable r Ix2 (Pixel cs e), MonadThrow m,
ColorSpace cs i e) =>
f -> ByteString -> m (Image r cs e, Maybe ByteString)
decodeAutoNetpbmImage Auto PBM
f)
, Auto PGM
-> (forall (m :: * -> *).
MonadThrow m =>
Auto PGM -> ByteString -> m (Image r cs e))
-> Decode (Image r cs e)
forall f out.
FileFormat f =>
f
-> (forall (m :: * -> *). MonadThrow m => f -> ByteString -> m out)
-> Decode out
DecodeAs (PGM -> Auto PGM
forall f. f -> Auto f
Auto PGM
PGM) (\Auto PGM
f -> ((Image r cs e, Maybe ByteString) -> Image r cs e)
-> m (Image r cs e, Maybe ByteString) -> m (Image r cs e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Image r cs e, Maybe ByteString) -> Image r cs e
forall a b. (a, b) -> a
fst (m (Image r cs e, Maybe ByteString) -> m (Image r cs e))
-> (ByteString -> m (Image r cs e, Maybe ByteString))
-> ByteString
-> m (Image r cs e)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Auto PGM -> ByteString -> m (Image r cs e, Maybe ByteString)
forall f r cs e (m :: * -> *) i.
(FileFormat f, Mutable r Ix2 (Pixel cs e), MonadThrow m,
ColorSpace cs i e) =>
f -> ByteString -> m (Image r cs e, Maybe ByteString)
decodeAutoNetpbmImage Auto PGM
f)
, Auto PPM
-> (forall (m :: * -> *).
MonadThrow m =>
Auto PPM -> ByteString -> m (Image r cs e))
-> Decode (Image r cs e)
forall f out.
FileFormat f =>
f
-> (forall (m :: * -> *). MonadThrow m => f -> ByteString -> m out)
-> Decode out
DecodeAs (PPM -> Auto PPM
forall f. f -> Auto f
Auto PPM
PPM) (\Auto PPM
f -> ((Image r cs e, Maybe ByteString) -> Image r cs e)
-> m (Image r cs e, Maybe ByteString) -> m (Image r cs e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Image r cs e, Maybe ByteString) -> Image r cs e
forall a b. (a, b) -> a
fst (m (Image r cs e, Maybe ByteString) -> m (Image r cs e))
-> (ByteString -> m (Image r cs e, Maybe ByteString))
-> ByteString
-> m (Image r cs e)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Auto PPM -> ByteString -> m (Image r cs e, Maybe ByteString)
forall f r cs e (m :: * -> *) i.
(FileFormat f, Mutable r Ix2 (Pixel cs e), MonadThrow m,
ColorSpace cs i e) =>
f -> ByteString -> m (Image r cs e, Maybe ByteString)
decodeAutoNetpbmImage Auto PPM
f)
]