{-# 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
, selectFileFormat
, Encode(..)
, encodeImageM
, encodeAdhocM
, writableAdhoc
, imageWriteFormats
, imageWriteAutoFormats
, Decode(..)
, decodeImageM
, decodeAdhocM
, readableAdhoc
, imageReadFormats
, imageReadAutoFormats
) where
import qualified Data.ByteString as B (ByteString)
import qualified Data.ByteString.Lazy as BL (ByteString)
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
data Encode out where
Encode
:: FileFormat f
=> f
-> (forall m. MonadThrow m => f -> out -> m BL.ByteString)
-> Encode out
instance Show (Encode out) where
show :: Encode out -> String
show (Encode f
f forall (m :: * -> *). MonadThrow m => f -> out -> m ByteString
_) = f -> String
forall a. Show a => a -> String
show f
f
instance FileFormat (Encode out) where
ext :: Encode out -> String
ext (Encode f
f forall (m :: * -> *). MonadThrow m => f -> out -> m ByteString
_) = f -> String
forall f. FileFormat f => f -> String
ext f
f
exts :: Encode out -> [String]
exts (Encode f
f forall (m :: * -> *). MonadThrow m => f -> out -> m ByteString
_) = f -> [String]
forall f. FileFormat f => f -> [String]
exts f
f
encodeAdhocM :: MonadThrow m => Encode out -> out -> m BL.ByteString
encodeAdhocM :: Encode out -> out -> m ByteString
encodeAdhocM (Encode f
f forall (m :: * -> *). MonadThrow m => f -> out -> m ByteString
enc) = f -> out -> m ByteString
forall (m :: * -> *). MonadThrow m => f -> out -> m ByteString
enc f
f
writableAdhoc :: Writable f out => f -> Encode out
writableAdhoc :: f -> Encode out
writableAdhoc f
f = f
-> (forall (m :: * -> *). MonadThrow m => f -> out -> m ByteString)
-> Encode out
forall f out.
FileFormat f =>
f
-> (forall (m :: * -> *). MonadThrow m => f -> out -> m ByteString)
-> Encode out
Encode f
f (f -> WriteOptions f -> out -> m ByteString
forall f arr (m :: * -> *).
(Writable f arr, MonadThrow m) =>
f -> WriteOptions f -> arr -> m ByteString
`encodeM` WriteOptions f
forall a. Default a => a
def)
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
Encode (Image r cs e)
f <- [Encode (Image r cs e)] -> String -> m (Encode (Image r cs e))
forall f (m :: * -> *).
(FileFormat f, MonadThrow m) =>
[f] -> String -> m f
selectFileFormat [Encode (Image r cs e)]
formats String
path
Encode (Image r cs e) -> Image r cs e -> m ByteString
forall (m :: * -> *) out.
MonadThrow m =>
Encode out -> out -> m ByteString
encodeAdhocM 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 =
[ 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
Encode 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)
, 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
Encode 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)
, 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
Encode 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)
, 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
Encode 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
Encode 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)
, 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
Encode 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)
, 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
Encode 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)
]
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 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
Encode (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 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
Encode (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)
, 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
Encode (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 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
Encode (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
Encode (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
Encode (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 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
Encode (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)
]
data Decode out where
Decode
:: FileFormat f
=> f
-> (forall m. MonadThrow m => f -> B.ByteString -> m out)
-> Decode out
instance Show (Decode out) where
show :: Decode out -> String
show (Decode 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 (Decode 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 (Decode f
f forall (m :: * -> *).
MonadThrow m =>
f -> ByteString -> m (Image r cs e)
_) = f -> [String]
forall f. FileFormat f => f -> [String]
exts f
f
decodeAdhocM :: MonadThrow m => Decode out -> B.ByteString -> m out
decodeAdhocM :: Decode out -> ByteString -> m out
decodeAdhocM (Decode f
f forall (m :: * -> *). MonadThrow m => f -> ByteString -> m out
dec) = f -> ByteString -> m out
forall (m :: * -> *). MonadThrow m => f -> ByteString -> m out
dec f
f
readableAdhoc :: Readable f out => f -> Decode out
readableAdhoc :: f -> Decode out
readableAdhoc f
f = f
-> (forall (m :: * -> *). MonadThrow m => f -> ByteString -> m out)
-> Decode out
forall f out.
FileFormat f =>
f
-> (forall (m :: * -> *). MonadThrow m => f -> ByteString -> m out)
-> Decode out
Decode f
f forall f arr (m :: * -> *).
(Readable f arr, MonadThrow m) =>
f -> ByteString -> m arr
forall (m :: * -> *). MonadThrow m => f -> ByteString -> m out
decodeM
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
Decode (Image r cs e)
f <- [Decode (Image r cs e)] -> String -> m (Decode (Image r cs e))
forall f (m :: * -> *).
(FileFormat f, MonadThrow m) =>
[f] -> String -> m f
selectFileFormat [Decode (Image r cs e)]
formats String
path
Decode (Image r cs e) -> ByteString -> m (Image r cs e)
forall (m :: * -> *) out.
MonadThrow m =>
Decode out -> ByteString -> m out
decodeAdhocM Decode (Image r cs e)
f ByteString
bs
imageReadFormats :: ColorModel cs e => [Decode (Image S cs e)]
imageReadFormats :: [Decode (Image S cs e)]
imageReadFormats =
[ 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
Decode 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
, 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
Decode 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
, 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
Decode 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
, 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
Decode 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
Decode 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
Decode 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
, 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
Decode 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
, 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
Decode 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
Decode 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
Decode 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 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
Decode (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 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
Decode (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 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
Decode (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 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
Decode (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
Decode (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
Decode (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 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
Decode (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 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
Decode (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
Decode (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
Decode (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)
]