{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
-- |
-- Module      : Data.Massiv.Array.IO.Image.JuicyPixels.Base
-- Copyright   : (c) Alexey Kuleshevich 2019-2020
-- License     : BSD3
-- Maintainer  : Alexey Kuleshevich <lehins@yandex.ru>
-- Stability   : experimental
-- Portability : non-portable
--
module Data.Massiv.Array.IO.Image.JuicyPixels.Base
  ( showJP
  , convertWith
  , convertWithMetadata
  , convertAutoWith
  , convertAutoWithMetadata
  , convertSequenceWith
  , convertAutoSequenceWith
  , toJPImageY8
  , toJPImageY16
  , toJPImageY32
  , toJPImageYA8
  , toJPImageYA16
  , toJPImageYF
  , toJPImageRGB8
  , toJPImageRGB16
  , toJPImageRGBA8
  , toJPImageRGBA16
  , toJPImageRGBF
  , toJPImageYCbCr8
  , toJPImageCMYK8
  , toJPImageCMYK16
  , maybeJPImageY8
  , maybeJPImageY16
  , maybeJPImageY32
  , maybeJPImageYA8
  , maybeJPImageYA16
  , maybeJPImageYF
  , maybeJPImageRGB8
  , maybeJPImageRGB16
  , maybeJPImageRGBA8
  , maybeJPImageRGBA16
  , maybeJPImageRGBF
  , maybeJPImageYCbCr8
  , maybeJPImageCMYK8
  , maybeJPImageCMYK16
  , fromDynamicImage
  , fromDynamicImageM
  , fromDynamicImageAuto
  -- * Conversion to sRGB
  , toYCbCr8
  , toCMYK8
  , toCMYK16
  , toSRGB8
  , toSRGB16
  , toSRGBA8
  , toSRGBA16
  ) where

import qualified Codec.Picture as JP
import Control.Exception (assert)
import Control.Monad (msum, unless)
import Data.Massiv.Array as A
import Data.Massiv.Array.IO.Base
import Data.Typeable
import qualified Data.Vector.Storable as V
import Foreign.Storable (Storable(sizeOf))
import qualified Graphics.Pixel as CM
import Graphics.Pixel.ColorSpace
import Prelude as P

--------------------------------------------------------------------------------
-- Common JuciyPixels encoding/decoding functions ------------------------------
--------------------------------------------------------------------------------

convertWith ::
     (MonadThrow m, ColorModel cs e, FileFormat f)
  => f
  -> Either String JP.DynamicImage
  -> m (Image S cs e)
convertWith :: f -> Either String DynamicImage -> m (Image S cs e)
convertWith f
f = (String -> m (Image S cs e))
-> (DynamicImage -> m (Image S cs e))
-> Either String DynamicImage
-> m (Image S cs e)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (DecodeError -> m (Image S cs e)
forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM (DecodeError -> m (Image S cs e))
-> (String -> DecodeError) -> String -> m (Image S cs e)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> DecodeError
DecodeError) (f
-> (DynamicImage -> String)
-> (DynamicImage -> m (Maybe (Image S cs e)))
-> DynamicImage
-> m (Image S cs e)
forall r cs e a f (m :: * -> *).
(ColorModel cs e, FileFormat f, Typeable r, MonadThrow m) =>
f
-> (a -> String)
-> (a -> m (Maybe (Image r cs e)))
-> a
-> m (Image r cs e)
fromMaybeDecodeM f
f DynamicImage -> String
showJP DynamicImage -> m (Maybe (Image S cs e))
forall cs e (m :: * -> *).
(ColorModel cs e, MonadThrow m) =>
DynamicImage -> m (Maybe (Image S cs e))
fromDynamicImageM)


convertWithMetadata ::
     (MonadThrow m, ColorModel cs e, FileFormat f)
  => f
  -> Either String (JP.DynamicImage, Metadata f)
  -> m (Image S cs e, Metadata f)
convertWithMetadata :: f
-> Either String (DynamicImage, Metadata f)
-> m (Image S cs e, Metadata f)
convertWithMetadata f
f Either String (DynamicImage, Metadata f)
decoded =
  case Either String (DynamicImage, Metadata f)
decoded of
    Left String
err -> DecodeError -> m (Image S cs e, Metadata f)
forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM (DecodeError -> m (Image S cs e, Metadata f))
-> DecodeError -> m (Image S cs e, Metadata f)
forall a b. (a -> b) -> a -> b
$ String -> DecodeError
DecodeError String
err
    Right (DynamicImage
jp, Metadata f
meta) -> do
      Image S cs e
i <- f
-> (DynamicImage -> String)
-> (DynamicImage -> m (Maybe (Image S cs e)))
-> DynamicImage
-> m (Image S cs e)
forall r cs e a f (m :: * -> *).
(ColorModel cs e, FileFormat f, Typeable r, MonadThrow m) =>
f
-> (a -> String)
-> (a -> m (Maybe (Image r cs e)))
-> a
-> m (Image r cs e)
fromMaybeDecodeM f
f DynamicImage -> String
showJP DynamicImage -> m (Maybe (Image S cs e))
forall cs e (m :: * -> *).
(ColorModel cs e, MonadThrow m) =>
DynamicImage -> m (Maybe (Image S cs e))
fromDynamicImageM DynamicImage
jp
      (Image S cs e, Metadata f) -> m (Image S cs e, Metadata f)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Image S cs e
i, Metadata f
meta)

convertAutoWithMetadata ::
     (MonadThrow m, Mutable r Ix2 (Pixel cs e), ColorSpace cs i e)
  => Auto f
  -> Either String (JP.DynamicImage, Metadata f)
  -> m (Image r cs e, Metadata f)
convertAutoWithMetadata :: Auto f
-> Either String (DynamicImage, Metadata f)
-> m (Image r cs e, Metadata f)
convertAutoWithMetadata Auto f
_ Either String (DynamicImage, Metadata f)
decoded =
  case Either String (DynamicImage, Metadata f)
decoded of
    Left String
err -> DecodeError -> m (Image r cs e, Metadata f)
forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM (DecodeError -> m (Image r cs e, Metadata f))
-> DecodeError -> m (Image r cs e, Metadata f)
forall a b. (a -> b) -> a -> b
$ String -> DecodeError
DecodeError String
err
    Right (DynamicImage
jp, Metadata f
meta) -> do
      Image r cs e
i <- DynamicImage -> m (Image r cs e)
forall r cs i e (m :: * -> *).
(Mutable r Ix2 (Pixel cs e), ColorSpace cs i e, MonadThrow m) =>
DynamicImage -> m (Image r cs e)
fromDynamicImageAuto DynamicImage
jp
      (Image r cs e, Metadata f) -> m (Image r cs e, Metadata f)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Image r cs e
i, Metadata f
meta)

convertAutoWith ::
     (MonadThrow m, Mutable r Ix2 (Pixel cs e), ColorSpace cs i e)
  => Auto f
  -> Either String JP.DynamicImage
  -> m (Image r cs e)
convertAutoWith :: Auto f -> Either String DynamicImage -> m (Image r cs e)
convertAutoWith Auto f
_ = (String -> m (Image r cs e))
-> (DynamicImage -> m (Image r cs e))
-> Either String DynamicImage
-> m (Image r cs e)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (DecodeError -> m (Image r cs e)
forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM (DecodeError -> m (Image r cs e))
-> (String -> DecodeError) -> String -> m (Image r cs e)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> DecodeError
DecodeError) DynamicImage -> m (Image r cs e)
forall r cs i e (m :: * -> *).
(Mutable r Ix2 (Pixel cs e), ColorSpace cs i e, MonadThrow m) =>
DynamicImage -> m (Image r cs e)
fromDynamicImageAuto


convertSequenceWith ::
     (MonadThrow m, ColorModel cs e, FileFormat (Sequence f))
  => Sequence f
  -> Either String [JP.DynamicImage]
  -> m [Image S cs e]
convertSequenceWith :: Sequence f -> Either String [DynamicImage] -> m [Image S cs e]
convertSequenceWith Sequence f
f Either String [DynamicImage]
ejpImgs = do
  [DynamicImage]
jpImgs <- Either String [DynamicImage] -> m [DynamicImage]
forall (m :: * -> *) a. MonadThrow m => Either String a -> m a
decodeError Either String [DynamicImage]
ejpImgs
  (DynamicImage -> m (Image S cs e))
-> [DynamicImage] -> m [Image S cs e]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
P.traverse (Sequence f
-> (DynamicImage -> String)
-> (DynamicImage -> m (Maybe (Image S cs e)))
-> DynamicImage
-> m (Image S cs e)
forall r cs e a f (m :: * -> *).
(ColorModel cs e, FileFormat f, Typeable r, MonadThrow m) =>
f
-> (a -> String)
-> (a -> m (Maybe (Image r cs e)))
-> a
-> m (Image r cs e)
fromMaybeDecodeM Sequence f
f DynamicImage -> String
showJP DynamicImage -> m (Maybe (Image S cs e))
forall cs e (m :: * -> *).
(ColorModel cs e, MonadThrow m) =>
DynamicImage -> m (Maybe (Image S cs e))
fromDynamicImageM) [DynamicImage]
jpImgs


convertAutoSequenceWith ::
     (MonadThrow m, Mutable r Ix2 (Pixel cs e), ColorSpace cs i e)
  => Auto (Sequence f)
  -> Either String [JP.DynamicImage]
  -> m [Image r cs e]
convertAutoSequenceWith :: Auto (Sequence f)
-> Either String [DynamicImage] -> m [Image r cs e]
convertAutoSequenceWith Auto (Sequence f)
_ Either String [DynamicImage]
ejpImgs = do
  [DynamicImage]
jpImgs <- Either String [DynamicImage] -> m [DynamicImage]
forall (m :: * -> *) a. MonadThrow m => Either String a -> m a
decodeError Either String [DynamicImage]
ejpImgs
  (DynamicImage -> m (Image r cs e))
-> [DynamicImage] -> m [Image r cs e]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
P.traverse DynamicImage -> m (Image r cs e)
forall r cs i e (m :: * -> *).
(Mutable r Ix2 (Pixel cs e), ColorSpace cs i e, MonadThrow m) =>
DynamicImage -> m (Image r cs e)
fromDynamicImageAuto [DynamicImage]
jpImgs


fromDynamicImageM ::
     forall cs e m. (ColorModel cs e, MonadThrow m)
  => JP.DynamicImage
  -> m (Maybe (Image S cs e))
fromDynamicImageM :: DynamicImage -> m (Maybe (Image S cs e))
fromDynamicImageM DynamicImage
jpDynImg =
  case DynamicImage
jpDynImg of
    JP.ImageY8 Image Pixel8
jimg
      | Just Pixel cs e :~: Pixel (Y' SRGB) Pixel8
Refl <- (Maybe (Pixel cs e :~: Pixel (Y' SRGB) Pixel8)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel (Y' SRGB) Word8)) -> Image Pixel8 -> m (Maybe (Image S cs e))
forall px. Pixel px => Image px -> m (Maybe (Image S cs e))
justFromJP Image Pixel8
jimg
      | Just Pixel cs e :~: Pixel (Y D65) Pixel8
Refl <- (Maybe (Pixel cs e :~: Pixel (Y D65) Pixel8)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel (Y D65) Word8)) -> Image Pixel8 -> m (Maybe (Image S cs e))
forall px. Pixel px => Image px -> m (Maybe (Image S cs e))
justFromJP Image Pixel8
jimg
      | Just Pixel cs e :~: Pixel X Pixel8
Refl <- (Maybe (Pixel cs e :~: Pixel X Pixel8)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel CM.X Word8)) -> Image Pixel8 -> m (Maybe (Image S cs e))
forall px. Pixel px => Image px -> m (Maybe (Image S cs e))
justFromJP Image Pixel8
jimg
      | Bool
otherwise -> Maybe (Image S cs e) -> m (Maybe (Image S cs e))
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe (Image S cs e)
forall a. Maybe a
Nothing
    JP.ImageY16 Image Pixel16
jimg
      | Just Pixel cs e :~: Pixel (Y' SRGB) Pixel16
Refl <- (Maybe (Pixel cs e :~: Pixel (Y' SRGB) Pixel16)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel (Y' SRGB) Word16)) -> Image Pixel16 -> m (Maybe (Image S cs e))
forall px. Pixel px => Image px -> m (Maybe (Image S cs e))
justFromJP Image Pixel16
jimg
      | Just Pixel cs e :~: Pixel (Y D65) Pixel16
Refl <- (Maybe (Pixel cs e :~: Pixel (Y D65) Pixel16)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel (Y D65) Word16)) -> Image Pixel16 -> m (Maybe (Image S cs e))
forall px. Pixel px => Image px -> m (Maybe (Image S cs e))
justFromJP Image Pixel16
jimg
      | Just Pixel cs e :~: Pixel X Pixel16
Refl <- (Maybe (Pixel cs e :~: Pixel X Pixel16)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel CM.X Word16)) -> Image Pixel16 -> m (Maybe (Image S cs e))
forall px. Pixel px => Image px -> m (Maybe (Image S cs e))
justFromJP Image Pixel16
jimg
      | Bool
otherwise -> Maybe (Image S cs e) -> m (Maybe (Image S cs e))
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe (Image S cs e)
forall a. Maybe a
Nothing
    JP.ImageY32 Image Pixel32
jimg
      | Just Pixel cs e :~: Pixel (Y' SRGB) Pixel32
Refl <- (Maybe (Pixel cs e :~: Pixel (Y' SRGB) Pixel32)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel (Y' SRGB) Word32)) -> Image Pixel32 -> m (Maybe (Image S cs e))
forall px. Pixel px => Image px -> m (Maybe (Image S cs e))
justFromJP Image Pixel32
jimg
      | Just Pixel cs e :~: Pixel (Y D65) Pixel32
Refl <- (Maybe (Pixel cs e :~: Pixel (Y D65) Pixel32)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel (Y D65) Word32)) -> Image Pixel32 -> m (Maybe (Image S cs e))
forall px. Pixel px => Image px -> m (Maybe (Image S cs e))
justFromJP Image Pixel32
jimg
      | Just Pixel cs e :~: Pixel X Pixel32
Refl <- (Maybe (Pixel cs e :~: Pixel X Pixel32)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel CM.X Word32)) -> Image Pixel32 -> m (Maybe (Image S cs e))
forall px. Pixel px => Image px -> m (Maybe (Image S cs e))
justFromJP Image Pixel32
jimg
      | Bool
otherwise -> Maybe (Image S cs e) -> m (Maybe (Image S cs e))
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe (Image S cs e)
forall a. Maybe a
Nothing
    JP.ImageYF Image PixelF
jimg
      | Just Pixel cs e :~: Pixel (Y' SRGB) PixelF
Refl <- (Maybe (Pixel cs e :~: Pixel (Y' SRGB) PixelF)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel (Y' SRGB) Float)) -> Image PixelF -> m (Maybe (Image S cs e))
forall px. Pixel px => Image px -> m (Maybe (Image S cs e))
justFromJP Image PixelF
jimg
      | Just Pixel cs e :~: Pixel (Y D65) PixelF
Refl <- (Maybe (Pixel cs e :~: Pixel (Y D65) PixelF)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel (Y D65) Float)) -> Image PixelF -> m (Maybe (Image S cs e))
forall px. Pixel px => Image px -> m (Maybe (Image S cs e))
justFromJP Image PixelF
jimg
      | Just Pixel cs e :~: Pixel X PixelF
Refl <- (Maybe (Pixel cs e :~: Pixel X PixelF)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel CM.X Float)) -> Image PixelF -> m (Maybe (Image S cs e))
forall px. Pixel px => Image px -> m (Maybe (Image S cs e))
justFromJP Image PixelF
jimg
      | Bool
otherwise -> Maybe (Image S cs e) -> m (Maybe (Image S cs e))
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe (Image S cs e)
forall a. Maybe a
Nothing
    JP.ImageYA8 Image PixelYA8
jimg
      | Just Pixel cs e :~: Pixel (Alpha (Y' SRGB)) Pixel8
Refl <- (Maybe (Pixel cs e :~: Pixel (Alpha (Y' SRGB)) Pixel8)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel (Alpha (Y' SRGB)) Word8)) -> Image PixelYA8 -> m (Maybe (Image S cs e))
forall px. Pixel px => Image px -> m (Maybe (Image S cs e))
justFromJP Image PixelYA8
jimg
      | Just Pixel cs e :~: Pixel (Alpha (Y D65)) Pixel8
Refl <- (Maybe (Pixel cs e :~: Pixel (Alpha (Y D65)) Pixel8)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel (Alpha (Y D65)) Word8)) -> Image PixelYA8 -> m (Maybe (Image S cs e))
forall px. Pixel px => Image px -> m (Maybe (Image S cs e))
justFromJP Image PixelYA8
jimg
      | Just Pixel cs e :~: Pixel (Alpha X) Pixel8
Refl <- (Maybe (Pixel cs e :~: Pixel (Alpha X) Pixel8)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel (Alpha CM.X) Word8)) -> Image PixelYA8 -> m (Maybe (Image S cs e))
forall px. Pixel px => Image px -> m (Maybe (Image S cs e))
justFromJP Image PixelYA8
jimg
      | Bool
otherwise -> Maybe (Image S cs e) -> m (Maybe (Image S cs e))
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe (Image S cs e)
forall a. Maybe a
Nothing
    JP.ImageYA16 Image PixelYA16
jimg
      | Just Pixel cs e :~: Pixel (Alpha (Y' SRGB)) Pixel16
Refl <- (Maybe (Pixel cs e :~: Pixel (Alpha (Y' SRGB)) Pixel16)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel (Alpha (Y' SRGB)) Word16)) -> Image PixelYA16 -> m (Maybe (Image S cs e))
forall px. Pixel px => Image px -> m (Maybe (Image S cs e))
justFromJP Image PixelYA16
jimg
      | Just Pixel cs e :~: Pixel (Alpha (Y D65)) Pixel16
Refl <- (Maybe (Pixel cs e :~: Pixel (Alpha (Y D65)) Pixel16)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel (Alpha (Y D65)) Word16)) -> Image PixelYA16 -> m (Maybe (Image S cs e))
forall px. Pixel px => Image px -> m (Maybe (Image S cs e))
justFromJP Image PixelYA16
jimg
      | Just Pixel cs e :~: Pixel (Alpha X) Pixel16
Refl <- (Maybe (Pixel cs e :~: Pixel (Alpha X) Pixel16)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel (Alpha CM.X) Word16)) -> Image PixelYA16 -> m (Maybe (Image S cs e))
forall px. Pixel px => Image px -> m (Maybe (Image S cs e))
justFromJP Image PixelYA16
jimg
      | Bool
otherwise -> Maybe (Image S cs e) -> m (Maybe (Image S cs e))
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe (Image S cs e)
forall a. Maybe a
Nothing
    JP.ImageRGB8 Image PixelRGB8
jimg
      | Just Pixel cs e :~: Pixel (SRGB 'NonLinear) Pixel8
Refl <- (Maybe (Pixel cs e :~: Pixel (SRGB 'NonLinear) Pixel8)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel (SRGB 'NonLinear) Word8)) -> Image PixelRGB8 -> m (Maybe (Image S cs e))
forall px. Pixel px => Image px -> m (Maybe (Image S cs e))
justFromJP Image PixelRGB8
jimg
      | Just Pixel cs e :~: Pixel (AdobeRGB 'NonLinear) Pixel8
Refl <- (Maybe (Pixel cs e :~: Pixel (AdobeRGB 'NonLinear) Pixel8)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel (AdobeRGB 'NonLinear) Word8)) ->
        Image PixelRGB8 -> m (Maybe (Image S cs e))
forall px. Pixel px => Image px -> m (Maybe (Image S cs e))
justFromJP Image PixelRGB8
jimg
      | Just Pixel cs e :~: Pixel RGB Pixel8
Refl <- (Maybe (Pixel cs e :~: Pixel RGB Pixel8)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel CM.RGB Word8)) -> Image PixelRGB8 -> m (Maybe (Image S cs e))
forall px. Pixel px => Image px -> m (Maybe (Image S cs e))
justFromJP Image PixelRGB8
jimg
      | Bool
otherwise -> Maybe (Image S cs e) -> m (Maybe (Image S cs e))
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe (Image S cs e)
forall a. Maybe a
Nothing
    JP.ImageRGB16 Image PixelRGB16
jimg
      | Just Pixel cs e :~: Pixel (SRGB 'NonLinear) Pixel16
Refl <- (Maybe (Pixel cs e :~: Pixel (SRGB 'NonLinear) Pixel16)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel (SRGB 'NonLinear) Word16)) -> Image PixelRGB16 -> m (Maybe (Image S cs e))
forall px. Pixel px => Image px -> m (Maybe (Image S cs e))
justFromJP Image PixelRGB16
jimg
      | Just Pixel cs e :~: Pixel (AdobeRGB 'NonLinear) Pixel16
Refl <- (Maybe (Pixel cs e :~: Pixel (AdobeRGB 'NonLinear) Pixel16)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel (AdobeRGB 'NonLinear) Word16)) ->
        Image PixelRGB16 -> m (Maybe (Image S cs e))
forall px. Pixel px => Image px -> m (Maybe (Image S cs e))
justFromJP Image PixelRGB16
jimg
      | Just Pixel cs e :~: Pixel RGB Pixel16
Refl <- (Maybe (Pixel cs e :~: Pixel RGB Pixel16)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel CM.RGB Word16)) -> Image PixelRGB16 -> m (Maybe (Image S cs e))
forall px. Pixel px => Image px -> m (Maybe (Image S cs e))
justFromJP Image PixelRGB16
jimg
      | Bool
otherwise -> Maybe (Image S cs e) -> m (Maybe (Image S cs e))
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe (Image S cs e)
forall a. Maybe a
Nothing
    JP.ImageRGBF Image PixelRGBF
jimg
      | Just Pixel cs e :~: Pixel (SRGB 'NonLinear) PixelF
Refl <- (Maybe (Pixel cs e :~: Pixel (SRGB 'NonLinear) PixelF)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel (SRGB 'NonLinear) Float)) -> Image PixelRGBF -> m (Maybe (Image S cs e))
forall px. Pixel px => Image px -> m (Maybe (Image S cs e))
justFromJP Image PixelRGBF
jimg
      | Just Pixel cs e :~: Pixel (AdobeRGB 'NonLinear) PixelF
Refl <- (Maybe (Pixel cs e :~: Pixel (AdobeRGB 'NonLinear) PixelF)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel (AdobeRGB 'NonLinear) Float)) ->
        Image PixelRGBF -> m (Maybe (Image S cs e))
forall px. Pixel px => Image px -> m (Maybe (Image S cs e))
justFromJP Image PixelRGBF
jimg
      | Just Pixel cs e :~: Pixel RGB PixelF
Refl <- (Maybe (Pixel cs e :~: Pixel RGB PixelF)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel CM.RGB Float)) -> Image PixelRGBF -> m (Maybe (Image S cs e))
forall px. Pixel px => Image px -> m (Maybe (Image S cs e))
justFromJP Image PixelRGBF
jimg
      | Bool
otherwise -> Maybe (Image S cs e) -> m (Maybe (Image S cs e))
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe (Image S cs e)
forall a. Maybe a
Nothing
    JP.ImageRGBA8 Image PixelRGBA8
jimg
      | Just Pixel cs e :~: Pixel (Alpha (SRGB 'NonLinear)) Pixel8
Refl <- (Maybe (Pixel cs e :~: Pixel (Alpha (SRGB 'NonLinear)) Pixel8)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel (Alpha (SRGB 'NonLinear)) Word8)) ->
        Image PixelRGBA8 -> m (Maybe (Image S cs e))
forall px. Pixel px => Image px -> m (Maybe (Image S cs e))
justFromJP Image PixelRGBA8
jimg
      | Just Pixel cs e :~: Pixel (Alpha (AdobeRGB 'NonLinear)) Pixel8
Refl <- (Maybe (Pixel cs e :~: Pixel (Alpha (AdobeRGB 'NonLinear)) Pixel8)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel (Alpha (AdobeRGB 'NonLinear)) Word8)) ->
        Image PixelRGBA8 -> m (Maybe (Image S cs e))
forall px. Pixel px => Image px -> m (Maybe (Image S cs e))
justFromJP Image PixelRGBA8
jimg
      | Just Pixel cs e :~: Pixel (Alpha RGB) Pixel8
Refl <- (Maybe (Pixel cs e :~: Pixel (Alpha RGB) Pixel8)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel (Alpha CM.RGB) Word8)) -> Image PixelRGBA8 -> m (Maybe (Image S cs e))
forall px. Pixel px => Image px -> m (Maybe (Image S cs e))
justFromJP Image PixelRGBA8
jimg
      | Bool
otherwise -> Maybe (Image S cs e) -> m (Maybe (Image S cs e))
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe (Image S cs e)
forall a. Maybe a
Nothing
    JP.ImageRGBA16 Image PixelRGBA16
jimg
      | Just Pixel cs e :~: Pixel (Alpha (SRGB 'NonLinear)) Pixel16
Refl <- (Maybe (Pixel cs e :~: Pixel (Alpha (SRGB 'NonLinear)) Pixel16)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel (Alpha (SRGB 'NonLinear)) Word16)) ->
        Image PixelRGBA16 -> m (Maybe (Image S cs e))
forall px. Pixel px => Image px -> m (Maybe (Image S cs e))
justFromJP Image PixelRGBA16
jimg
      | Just Pixel cs e :~: Pixel (Alpha (AdobeRGB 'NonLinear)) Pixel16
Refl <- (Maybe (Pixel cs e :~: Pixel (Alpha (AdobeRGB 'NonLinear)) Pixel16)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel (Alpha (AdobeRGB 'NonLinear)) Word16)) ->
        Image PixelRGBA16 -> m (Maybe (Image S cs e))
forall px. Pixel px => Image px -> m (Maybe (Image S cs e))
justFromJP Image PixelRGBA16
jimg
      | Just Pixel cs e :~: Pixel (Alpha RGB) Pixel16
Refl <- (Maybe (Pixel cs e :~: Pixel (Alpha RGB) Pixel16)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel (Alpha CM.RGB) Word16)) -> Image PixelRGBA16 -> m (Maybe (Image S cs e))
forall px. Pixel px => Image px -> m (Maybe (Image S cs e))
justFromJP Image PixelRGBA16
jimg
      | Bool
otherwise -> Maybe (Image S cs e) -> m (Maybe (Image S cs e))
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe (Image S cs e)
forall a. Maybe a
Nothing
    JP.ImageYCbCr8 Image PixelYCbCr8
jimg
      | Just Pixel cs e :~: Pixel (Y'CbCr SRGB) Pixel8
Refl <- (Maybe (Pixel cs e :~: Pixel (Y'CbCr SRGB) Pixel8)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel (Y'CbCr SRGB) Word8)) -> Image PixelYCbCr8 -> m (Maybe (Image S cs e))
forall px. Pixel px => Image px -> m (Maybe (Image S cs e))
justFromJP Image PixelYCbCr8
jimg
      | Just Pixel cs e :~: Pixel (Y'CbCr AdobeRGB) Pixel8
Refl <- (Maybe (Pixel cs e :~: Pixel (Y'CbCr AdobeRGB) Pixel8)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel (Y'CbCr AdobeRGB) Word8)) -> Image PixelYCbCr8 -> m (Maybe (Image S cs e))
forall px. Pixel px => Image px -> m (Maybe (Image S cs e))
justFromJP Image PixelYCbCr8
jimg
      | Just Pixel cs e :~: Pixel YCbCr Pixel8
Refl <- (Maybe (Pixel cs e :~: Pixel YCbCr Pixel8)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel CM.YCbCr Word8)) -> Image PixelYCbCr8 -> m (Maybe (Image S cs e))
forall px. Pixel px => Image px -> m (Maybe (Image S cs e))
justFromJP Image PixelYCbCr8
jimg
      | Bool
otherwise -> Maybe (Image S cs e) -> m (Maybe (Image S cs e))
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe (Image S cs e)
forall a. Maybe a
Nothing
    JP.ImageCMYK8 Image PixelCMYK8
jimg
      | Just Pixel cs e :~: Pixel (CMYK (SRGB 'NonLinear)) Pixel8
Refl <- (Maybe (Pixel cs e :~: Pixel (CMYK (SRGB 'NonLinear)) Pixel8)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel (CMYK (SRGB 'NonLinear)) Word8)) ->
        Image PixelCMYK8 -> m (Maybe (Image S cs e))
forall px. Pixel px => Image px -> m (Maybe (Image S cs e))
justFromJP Image PixelCMYK8
jimg
      | Just Pixel cs e :~: Pixel (CMYK (AdobeRGB 'NonLinear)) Pixel8
Refl <- (Maybe (Pixel cs e :~: Pixel (CMYK (AdobeRGB 'NonLinear)) Pixel8)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel (CMYK (AdobeRGB 'NonLinear)) Word8)) ->
        Image PixelCMYK8 -> m (Maybe (Image S cs e))
forall px. Pixel px => Image px -> m (Maybe (Image S cs e))
justFromJP Image PixelCMYK8
jimg
      | Just Pixel cs e :~: Pixel CMYK Pixel8
Refl <- (Maybe (Pixel cs e :~: Pixel CMYK Pixel8)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel CM.CMYK Word8)) -> Image PixelCMYK8 -> m (Maybe (Image S cs e))
forall px. Pixel px => Image px -> m (Maybe (Image S cs e))
justFromJP Image PixelCMYK8
jimg
      | Bool
otherwise -> Maybe (Image S cs e) -> m (Maybe (Image S cs e))
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe (Image S cs e)
forall a. Maybe a
Nothing
    JP.ImageCMYK16 Image PixelCMYK16
jimg
      | Just Pixel cs e :~: Pixel (CMYK (SRGB 'NonLinear)) Pixel16
Refl <- (Maybe (Pixel cs e :~: Pixel (CMYK (SRGB 'NonLinear)) Pixel16)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel (CMYK (SRGB 'NonLinear)) Word16)) ->
        Image PixelCMYK16 -> m (Maybe (Image S cs e))
forall px. Pixel px => Image px -> m (Maybe (Image S cs e))
justFromJP Image PixelCMYK16
jimg
      | Just Pixel cs e :~: Pixel (CMYK (AdobeRGB 'NonLinear)) Pixel16
Refl <- (Maybe (Pixel cs e :~: Pixel (CMYK (AdobeRGB 'NonLinear)) Pixel16)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel (CMYK (AdobeRGB 'NonLinear)) Word16)) ->
        Image PixelCMYK16 -> m (Maybe (Image S cs e))
forall px. Pixel px => Image px -> m (Maybe (Image S cs e))
justFromJP Image PixelCMYK16
jimg
      | Just Pixel cs e :~: Pixel CMYK Pixel16
Refl <- (Maybe (Pixel cs e :~: Pixel CMYK Pixel16)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel CM.CMYK Word16)) -> Image PixelCMYK16 -> m (Maybe (Image S cs e))
forall px. Pixel px => Image px -> m (Maybe (Image S cs e))
justFromJP Image PixelCMYK16
jimg
      | Bool
otherwise -> Maybe (Image S cs e) -> m (Maybe (Image S cs e))
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe (Image S cs e)
forall a. Maybe a
Nothing
  where
    justFromJP :: JP.Pixel px => JP.Image px -> m (Maybe (Image S cs e))
    justFromJP :: Image px -> m (Maybe (Image S cs e))
justFromJP = (Image S cs e -> Maybe (Image S cs e))
-> m (Image S cs e) -> m (Maybe (Image S cs e))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Image S cs e -> Maybe (Image S cs e)
forall a. a -> Maybe a
Just (m (Image S cs e) -> m (Maybe (Image S cs e)))
-> (Image px -> m (Image S cs e))
-> Image px
-> m (Maybe (Image S cs e))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Image px -> m (Image S cs e)
forall jpx cs e (m :: * -> *).
(Storable (Pixel cs e), Storable e, Pixel jpx, MonadThrow m) =>
Image jpx -> m (Image S cs e)
fromJPImageUnsafeM

fromDynamicImage ::
     forall cs e. ColorModel cs e
  => JP.DynamicImage
  -> Maybe (Image S cs e)
fromDynamicImage :: DynamicImage -> Maybe (Image S cs e)
fromDynamicImage DynamicImage
jpDynImg =
  case DynamicImage
jpDynImg of
    JP.ImageY8 Image Pixel8
jimg -> do
      Pixel cs e :~: Pixel X Pixel8
Refl <- Maybe (Pixel cs e :~: Pixel X Pixel8)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel CM.X Word8)
      Image Pixel8 -> Maybe (Image S cs e)
forall jpx cs e (m :: * -> *).
(Storable (Pixel cs e), Storable e, Pixel jpx, MonadThrow m) =>
Image jpx -> m (Image S cs e)
fromJPImageUnsafeM Image Pixel8
jimg
    JP.ImageY16 Image Pixel16
jimg -> do
      Pixel cs e :~: Pixel X Pixel16
Refl <- Maybe (Pixel cs e :~: Pixel X Pixel16)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel CM.X Word16)
      Image Pixel16 -> Maybe (Image S cs e)
forall jpx cs e (m :: * -> *).
(Storable (Pixel cs e), Storable e, Pixel jpx, MonadThrow m) =>
Image jpx -> m (Image S cs e)
fromJPImageUnsafeM Image Pixel16
jimg
    JP.ImageY32 Image Pixel32
jimg -> do
      Pixel cs e :~: Pixel X Pixel32
Refl <- Maybe (Pixel cs e :~: Pixel X Pixel32)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel CM.X Word32)
      Image Pixel32 -> Maybe (Image S cs e)
forall jpx cs e (m :: * -> *).
(Storable (Pixel cs e), Storable e, Pixel jpx, MonadThrow m) =>
Image jpx -> m (Image S cs e)
fromJPImageUnsafeM Image Pixel32
jimg
    JP.ImageYF Image PixelF
jimg -> do
      Pixel cs e :~: Pixel X PixelF
Refl <- Maybe (Pixel cs e :~: Pixel X PixelF)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel CM.X Float)
      Image PixelF -> Maybe (Image S cs e)
forall jpx cs e (m :: * -> *).
(Storable (Pixel cs e), Storable e, Pixel jpx, MonadThrow m) =>
Image jpx -> m (Image S cs e)
fromJPImageUnsafeM Image PixelF
jimg
    JP.ImageYA8 Image PixelYA8
jimg -> do
      Pixel cs e :~: Pixel (Alpha X) Pixel8
Refl <- Maybe (Pixel cs e :~: Pixel (Alpha X) Pixel8)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel (Alpha CM.X) Word8)
      Image PixelYA8 -> Maybe (Image S cs e)
forall jpx cs e (m :: * -> *).
(Storable (Pixel cs e), Storable e, Pixel jpx, MonadThrow m) =>
Image jpx -> m (Image S cs e)
fromJPImageUnsafeM Image PixelYA8
jimg
    JP.ImageYA16 Image PixelYA16
jimg -> do
      Pixel cs e :~: Pixel (Alpha X) Pixel16
Refl <- Maybe (Pixel cs e :~: Pixel (Alpha X) Pixel16)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel (Alpha CM.X) Word16)
      Image PixelYA16 -> Maybe (Image S cs e)
forall jpx cs e (m :: * -> *).
(Storable (Pixel cs e), Storable e, Pixel jpx, MonadThrow m) =>
Image jpx -> m (Image S cs e)
fromJPImageUnsafeM Image PixelYA16
jimg
    JP.ImageRGB8 Image PixelRGB8
jimg -> do
      Pixel cs e :~: Pixel RGB Pixel8
Refl <- Maybe (Pixel cs e :~: Pixel RGB Pixel8)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel CM.RGB Word8)
      Image PixelRGB8 -> Maybe (Image S cs e)
forall jpx cs e (m :: * -> *).
(Storable (Pixel cs e), Storable e, Pixel jpx, MonadThrow m) =>
Image jpx -> m (Image S cs e)
fromJPImageUnsafeM Image PixelRGB8
jimg
    JP.ImageRGB16 Image PixelRGB16
jimg -> do
      Pixel cs e :~: Pixel RGB Pixel16
Refl <- Maybe (Pixel cs e :~: Pixel RGB Pixel16)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel CM.RGB Word16)
      Image PixelRGB16 -> Maybe (Image S cs e)
forall jpx cs e (m :: * -> *).
(Storable (Pixel cs e), Storable e, Pixel jpx, MonadThrow m) =>
Image jpx -> m (Image S cs e)
fromJPImageUnsafeM Image PixelRGB16
jimg
    JP.ImageRGBF Image PixelRGBF
jimg -> do
      Pixel cs e :~: Pixel RGB PixelF
Refl <- Maybe (Pixel cs e :~: Pixel RGB PixelF)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel CM.RGB Float)
      Image PixelRGBF -> Maybe (Image S cs e)
forall jpx cs e (m :: * -> *).
(Storable (Pixel cs e), Storable e, Pixel jpx, MonadThrow m) =>
Image jpx -> m (Image S cs e)
fromJPImageUnsafeM Image PixelRGBF
jimg
    JP.ImageRGBA8 Image PixelRGBA8
jimg -> do
      Pixel cs e :~: Pixel (Alpha RGB) Pixel8
Refl <- Maybe (Pixel cs e :~: Pixel (Alpha RGB) Pixel8)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel (Alpha CM.RGB) Word8)
      Image PixelRGBA8 -> Maybe (Image S cs e)
forall jpx cs e (m :: * -> *).
(Storable (Pixel cs e), Storable e, Pixel jpx, MonadThrow m) =>
Image jpx -> m (Image S cs e)
fromJPImageUnsafeM Image PixelRGBA8
jimg
    JP.ImageRGBA16 Image PixelRGBA16
jimg -> do
      Pixel cs e :~: Pixel (Alpha RGB) Pixel16
Refl <- Maybe (Pixel cs e :~: Pixel (Alpha RGB) Pixel16)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel (Alpha CM.RGB) Word16)
      Image PixelRGBA16 -> Maybe (Image S cs e)
forall jpx cs e (m :: * -> *).
(Storable (Pixel cs e), Storable e, Pixel jpx, MonadThrow m) =>
Image jpx -> m (Image S cs e)
fromJPImageUnsafeM Image PixelRGBA16
jimg
    JP.ImageYCbCr8 Image PixelYCbCr8
jimg -> do
      Pixel cs e :~: Pixel YCbCr Pixel8
Refl <- Maybe (Pixel cs e :~: Pixel YCbCr Pixel8)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel CM.YCbCr Word8)
      Image PixelYCbCr8 -> Maybe (Image S cs e)
forall jpx cs e (m :: * -> *).
(Storable (Pixel cs e), Storable e, Pixel jpx, MonadThrow m) =>
Image jpx -> m (Image S cs e)
fromJPImageUnsafeM Image PixelYCbCr8
jimg
    JP.ImageCMYK8 Image PixelCMYK8
jimg -> do
      Pixel cs e :~: Pixel CMYK Pixel8
Refl <- Maybe (Pixel cs e :~: Pixel CMYK Pixel8)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel CM.CMYK Word8)
      Image PixelCMYK8 -> Maybe (Image S cs e)
forall jpx cs e (m :: * -> *).
(Storable (Pixel cs e), Storable e, Pixel jpx, MonadThrow m) =>
Image jpx -> m (Image S cs e)
fromJPImageUnsafeM Image PixelCMYK8
jimg
    JP.ImageCMYK16 Image PixelCMYK16
jimg -> do
      Pixel cs e :~: Pixel CMYK Pixel16
Refl <- Maybe (Pixel cs e :~: Pixel CMYK Pixel16)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (Pixel cs e :~: Pixel CM.CMYK Word16)
      Image PixelCMYK16 -> Maybe (Image S cs e)
forall jpx cs e (m :: * -> *).
(Storable (Pixel cs e), Storable e, Pixel jpx, MonadThrow m) =>
Image jpx -> m (Image S cs e)
fromJPImageUnsafeM Image PixelCMYK16
jimg
{-# DEPRECATED fromDynamicImage "In favor of `fromDynamicImageM`" #-}

fromDynamicImageAuto ::
     forall r cs i e m. (Mutable r Ix2 (Pixel cs e), ColorSpace cs i e, MonadThrow m)
  => JP.DynamicImage
  -> m (Image r cs e)
fromDynamicImageAuto :: DynamicImage -> m (Image r cs e)
fromDynamicImageAuto DynamicImage
jpDynImg =
  case DynamicImage
jpDynImg of
    JP.ImageY8 Image Pixel8
jimg ->
      Array D Ix2 (Pixel cs e) -> Image r cs e
forall r ix e r'.
(Mutable r ix e, Load r' ix e) =>
Array r' ix e -> Array r ix e
compute (Array D Ix2 (Pixel cs e) -> Image r cs e)
-> (Image S (Y D65) Pixel8 -> Array D Ix2 (Pixel cs e))
-> Image S (Y D65) Pixel8
-> Image r cs e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Image S (Y D65) Pixel8 -> Array D Ix2 (Pixel cs e)
forall r' cs' e' i' cs i e.
(Source r' Ix2 (Pixel cs' e'), ColorSpace cs' i' e',
 ColorSpace cs i e) =>
Image r' cs' e' -> Image D cs e
convertImage (Image S (Y D65) Pixel8 -> Image r cs e)
-> m (Image S (Y D65) Pixel8) -> m (Image r cs e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Image Pixel8 -> m (Image S (Y D65) Pixel8)
forall jpx cs e (m :: * -> *).
(Storable (Pixel cs e), Storable e, Pixel jpx, MonadThrow m) =>
Image jpx -> m (Image S cs e)
fromJPImageUnsafeM Image Pixel8
jimg :: m (Image S (Y D65) Word8))
    JP.ImageY16 Image Pixel16
jimg ->
      Array D Ix2 (Pixel cs e) -> Image r cs e
forall r ix e r'.
(Mutable r ix e, Load r' ix e) =>
Array r' ix e -> Array r ix e
compute (Array D Ix2 (Pixel cs e) -> Image r cs e)
-> (Image S (Y D65) Pixel16 -> Array D Ix2 (Pixel cs e))
-> Image S (Y D65) Pixel16
-> Image r cs e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Image S (Y D65) Pixel16 -> Array D Ix2 (Pixel cs e)
forall r' cs' e' i' cs i e.
(Source r' Ix2 (Pixel cs' e'), ColorSpace cs' i' e',
 ColorSpace cs i e) =>
Image r' cs' e' -> Image D cs e
convertImage (Image S (Y D65) Pixel16 -> Image r cs e)
-> m (Image S (Y D65) Pixel16) -> m (Image r cs e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Image Pixel16 -> m (Image S (Y D65) Pixel16)
forall jpx cs e (m :: * -> *).
(Storable (Pixel cs e), Storable e, Pixel jpx, MonadThrow m) =>
Image jpx -> m (Image S cs e)
fromJPImageUnsafeM Image Pixel16
jimg :: m (Image S (Y D65) Word16))
    JP.ImageY32 Image Pixel32
jimg ->
      Array D Ix2 (Pixel cs e) -> Image r cs e
forall r ix e r'.
(Mutable r ix e, Load r' ix e) =>
Array r' ix e -> Array r ix e
compute (Array D Ix2 (Pixel cs e) -> Image r cs e)
-> (Image S (Y D65) Pixel32 -> Array D Ix2 (Pixel cs e))
-> Image S (Y D65) Pixel32
-> Image r cs e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Image S (Y D65) Pixel32 -> Array D Ix2 (Pixel cs e)
forall r' cs' e' i' cs i e.
(Source r' Ix2 (Pixel cs' e'), ColorSpace cs' i' e',
 ColorSpace cs i e) =>
Image r' cs' e' -> Image D cs e
convertImage (Image S (Y D65) Pixel32 -> Image r cs e)
-> m (Image S (Y D65) Pixel32) -> m (Image r cs e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Image Pixel32 -> m (Image S (Y D65) Pixel32)
forall jpx cs e (m :: * -> *).
(Storable (Pixel cs e), Storable e, Pixel jpx, MonadThrow m) =>
Image jpx -> m (Image S cs e)
fromJPImageUnsafeM Image Pixel32
jimg :: m (Image S (Y D65) Word32))
    JP.ImageYF Image PixelF
jimg ->
      Array D Ix2 (Pixel cs e) -> Image r cs e
forall r ix e r'.
(Mutable r ix e, Load r' ix e) =>
Array r' ix e -> Array r ix e
compute (Array D Ix2 (Pixel cs e) -> Image r cs e)
-> (Image S (Y D65) PixelF -> Array D Ix2 (Pixel cs e))
-> Image S (Y D65) PixelF
-> Image r cs e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Image S (Y D65) PixelF -> Array D Ix2 (Pixel cs e)
forall r' cs' e' i' cs i e.
(Source r' Ix2 (Pixel cs' e'), ColorSpace cs' i' e',
 ColorSpace cs i e) =>
Image r' cs' e' -> Image D cs e
convertImage (Image S (Y D65) PixelF -> Image r cs e)
-> m (Image S (Y D65) PixelF) -> m (Image r cs e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Image PixelF -> m (Image S (Y D65) PixelF)
forall jpx cs e (m :: * -> *).
(Storable (Pixel cs e), Storable e, Pixel jpx, MonadThrow m) =>
Image jpx -> m (Image S cs e)
fromJPImageUnsafeM Image PixelF
jimg :: m (Image S (Y D65) Float))
    JP.ImageYA8 Image PixelYA8
jimg ->
      Array D Ix2 (Pixel cs e) -> Image r cs e
forall r ix e r'.
(Mutable r ix e, Load r' ix e) =>
Array r' ix e -> Array r ix e
compute (Array D Ix2 (Pixel cs e) -> Image r cs e)
-> (Image S (Alpha (Y D65)) Pixel8 -> Array D Ix2 (Pixel cs e))
-> Image S (Alpha (Y D65)) Pixel8
-> Image r cs e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Image S (Alpha (Y D65)) Pixel8 -> Array D Ix2 (Pixel cs e)
forall r' cs' e' i' cs i e.
(Source r' Ix2 (Pixel cs' e'), ColorSpace cs' i' e',
 ColorSpace cs i e) =>
Image r' cs' e' -> Image D cs e
convertImage (Image S (Alpha (Y D65)) Pixel8 -> Image r cs e)
-> m (Image S (Alpha (Y D65)) Pixel8) -> m (Image r cs e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Image PixelYA8 -> m (Image S (Alpha (Y D65)) Pixel8)
forall jpx cs e (m :: * -> *).
(Storable (Pixel cs e), Storable e, Pixel jpx, MonadThrow m) =>
Image jpx -> m (Image S cs e)
fromJPImageUnsafeM Image PixelYA8
jimg :: m (Image S (Alpha (Y D65)) Word8))
    JP.ImageYA16 Image PixelYA16
jimg ->
      Array D Ix2 (Pixel cs e) -> Image r cs e
forall r ix e r'.
(Mutable r ix e, Load r' ix e) =>
Array r' ix e -> Array r ix e
compute (Array D Ix2 (Pixel cs e) -> Image r cs e)
-> (Image S (Alpha (Y D65)) Pixel16 -> Array D Ix2 (Pixel cs e))
-> Image S (Alpha (Y D65)) Pixel16
-> Image r cs e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Image S (Alpha (Y D65)) Pixel16 -> Array D Ix2 (Pixel cs e)
forall r' cs' e' i' cs i e.
(Source r' Ix2 (Pixel cs' e'), ColorSpace cs' i' e',
 ColorSpace cs i e) =>
Image r' cs' e' -> Image D cs e
convertImage (Image S (Alpha (Y D65)) Pixel16 -> Image r cs e)
-> m (Image S (Alpha (Y D65)) Pixel16) -> m (Image r cs e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Image PixelYA16 -> m (Image S (Alpha (Y D65)) Pixel16)
forall jpx cs e (m :: * -> *).
(Storable (Pixel cs e), Storable e, Pixel jpx, MonadThrow m) =>
Image jpx -> m (Image S cs e)
fromJPImageUnsafeM Image PixelYA16
jimg :: m (Image S (Alpha (Y D65)) Word16))
    JP.ImageRGB8 Image PixelRGB8
jimg ->
      Array D Ix2 (Pixel cs e) -> Image r cs e
forall r ix e r'.
(Mutable r ix e, Load r' ix e) =>
Array r' ix e -> Array r ix e
compute (Array D Ix2 (Pixel cs e) -> Image r cs e)
-> (Image S (SRGB 'NonLinear) Pixel8 -> Array D Ix2 (Pixel cs e))
-> Image S (SRGB 'NonLinear) Pixel8
-> Image r cs e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Image S (SRGB 'NonLinear) Pixel8 -> Array D Ix2 (Pixel cs e)
forall r' cs' e' i' cs i e.
(Source r' Ix2 (Pixel cs' e'), ColorSpace cs' i' e',
 ColorSpace cs i e) =>
Image r' cs' e' -> Image D cs e
convertImage (Image S (SRGB 'NonLinear) Pixel8 -> Image r cs e)
-> m (Image S (SRGB 'NonLinear) Pixel8) -> m (Image r cs e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Image PixelRGB8 -> m (Image S (SRGB 'NonLinear) Pixel8)
forall jpx cs e (m :: * -> *).
(Storable (Pixel cs e), Storable e, Pixel jpx, MonadThrow m) =>
Image jpx -> m (Image S cs e)
fromJPImageUnsafeM Image PixelRGB8
jimg :: m (Image S (SRGB 'NonLinear) Word8))
    JP.ImageRGB16 Image PixelRGB16
jimg ->
      Array D Ix2 (Pixel cs e) -> Image r cs e
forall r ix e r'.
(Mutable r ix e, Load r' ix e) =>
Array r' ix e -> Array r ix e
compute (Array D Ix2 (Pixel cs e) -> Image r cs e)
-> (Image S (SRGB 'NonLinear) Pixel16 -> Array D Ix2 (Pixel cs e))
-> Image S (SRGB 'NonLinear) Pixel16
-> Image r cs e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Image S (SRGB 'NonLinear) Pixel16 -> Array D Ix2 (Pixel cs e)
forall r' cs' e' i' cs i e.
(Source r' Ix2 (Pixel cs' e'), ColorSpace cs' i' e',
 ColorSpace cs i e) =>
Image r' cs' e' -> Image D cs e
convertImage (Image S (SRGB 'NonLinear) Pixel16 -> Image r cs e)
-> m (Image S (SRGB 'NonLinear) Pixel16) -> m (Image r cs e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Image PixelRGB16 -> m (Image S (SRGB 'NonLinear) Pixel16)
forall jpx cs e (m :: * -> *).
(Storable (Pixel cs e), Storable e, Pixel jpx, MonadThrow m) =>
Image jpx -> m (Image S cs e)
fromJPImageUnsafeM Image PixelRGB16
jimg :: m (Image S (SRGB 'NonLinear) Word16))
    JP.ImageRGBF Image PixelRGBF
jimg ->
      Array D Ix2 (Pixel cs e) -> Image r cs e
forall r ix e r'.
(Mutable r ix e, Load r' ix e) =>
Array r' ix e -> Array r ix e
compute (Array D Ix2 (Pixel cs e) -> Image r cs e)
-> (Image S (SRGB 'NonLinear) PixelF -> Array D Ix2 (Pixel cs e))
-> Image S (SRGB 'NonLinear) PixelF
-> Image r cs e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Image S (SRGB 'NonLinear) PixelF -> Array D Ix2 (Pixel cs e)
forall r' cs' e' i' cs i e.
(Source r' Ix2 (Pixel cs' e'), ColorSpace cs' i' e',
 ColorSpace cs i e) =>
Image r' cs' e' -> Image D cs e
convertImage (Image S (SRGB 'NonLinear) PixelF -> Image r cs e)
-> m (Image S (SRGB 'NonLinear) PixelF) -> m (Image r cs e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Image PixelRGBF -> m (Image S (SRGB 'NonLinear) PixelF)
forall jpx cs e (m :: * -> *).
(Storable (Pixel cs e), Storable e, Pixel jpx, MonadThrow m) =>
Image jpx -> m (Image S cs e)
fromJPImageUnsafeM Image PixelRGBF
jimg :: m (Image S (SRGB 'NonLinear) Float))
    JP.ImageRGBA8 Image PixelRGBA8
jimg ->
      Array D Ix2 (Pixel cs e) -> Image r cs e
forall r ix e r'.
(Mutable r ix e, Load r' ix e) =>
Array r' ix e -> Array r ix e
compute (Array D Ix2 (Pixel cs e) -> Image r cs e)
-> (Image S (Alpha (SRGB 'NonLinear)) Pixel8
    -> Array D Ix2 (Pixel cs e))
-> Image S (Alpha (SRGB 'NonLinear)) Pixel8
-> Image r cs e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Image S (Alpha (SRGB 'NonLinear)) Pixel8
-> Array D Ix2 (Pixel cs e)
forall r' cs' e' i' cs i e.
(Source r' Ix2 (Pixel cs' e'), ColorSpace cs' i' e',
 ColorSpace cs i e) =>
Image r' cs' e' -> Image D cs e
convertImage (Image S (Alpha (SRGB 'NonLinear)) Pixel8 -> Image r cs e)
-> m (Image S (Alpha (SRGB 'NonLinear)) Pixel8) -> m (Image r cs e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
      (Image PixelRGBA8 -> m (Image S (Alpha (SRGB 'NonLinear)) Pixel8)
forall jpx cs e (m :: * -> *).
(Storable (Pixel cs e), Storable e, Pixel jpx, MonadThrow m) =>
Image jpx -> m (Image S cs e)
fromJPImageUnsafeM Image PixelRGBA8
jimg :: m (Image S (Alpha (SRGB 'NonLinear)) Word8))
    JP.ImageRGBA16 Image PixelRGBA16
jimg ->
      Array D Ix2 (Pixel cs e) -> Image r cs e
forall r ix e r'.
(Mutable r ix e, Load r' ix e) =>
Array r' ix e -> Array r ix e
compute (Array D Ix2 (Pixel cs e) -> Image r cs e)
-> (Image S (Alpha (SRGB 'NonLinear)) Pixel16
    -> Array D Ix2 (Pixel cs e))
-> Image S (Alpha (SRGB 'NonLinear)) Pixel16
-> Image r cs e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Image S (Alpha (SRGB 'NonLinear)) Pixel16
-> Array D Ix2 (Pixel cs e)
forall r' cs' e' i' cs i e.
(Source r' Ix2 (Pixel cs' e'), ColorSpace cs' i' e',
 ColorSpace cs i e) =>
Image r' cs' e' -> Image D cs e
convertImage (Image S (Alpha (SRGB 'NonLinear)) Pixel16 -> Image r cs e)
-> m (Image S (Alpha (SRGB 'NonLinear)) Pixel16)
-> m (Image r cs e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
      (Image PixelRGBA16 -> m (Image S (Alpha (SRGB 'NonLinear)) Pixel16)
forall jpx cs e (m :: * -> *).
(Storable (Pixel cs e), Storable e, Pixel jpx, MonadThrow m) =>
Image jpx -> m (Image S cs e)
fromJPImageUnsafeM Image PixelRGBA16
jimg :: m (Image S (Alpha (SRGB 'NonLinear)) Word16))
    JP.ImageYCbCr8 Image PixelYCbCr8
jimg ->
      Array D Ix2 (Pixel cs e) -> Image r cs e
forall r ix e r'.
(Mutable r ix e, Load r' ix e) =>
Array r' ix e -> Array r ix e
compute (Array D Ix2 (Pixel cs e) -> Image r cs e)
-> (Image S (Y'CbCr SRGB) Pixel8 -> Array D Ix2 (Pixel cs e))
-> Image S (Y'CbCr SRGB) Pixel8
-> Image r cs e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Image S (Y'CbCr SRGB) Pixel8 -> Array D Ix2 (Pixel cs e)
forall r' cs' e' i' cs i e.
(Source r' Ix2 (Pixel cs' e'), ColorSpace cs' i' e',
 ColorSpace cs i e) =>
Image r' cs' e' -> Image D cs e
convertImage (Image S (Y'CbCr SRGB) Pixel8 -> Image r cs e)
-> m (Image S (Y'CbCr SRGB) Pixel8) -> m (Image r cs e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
      (Image PixelYCbCr8 -> m (Image S (Y'CbCr SRGB) Pixel8)
forall jpx cs e (m :: * -> *).
(Storable (Pixel cs e), Storable e, Pixel jpx, MonadThrow m) =>
Image jpx -> m (Image S cs e)
fromJPImageUnsafeM Image PixelYCbCr8
jimg :: m (Image S (Y'CbCr SRGB) Word8))
    JP.ImageCMYK8 Image PixelCMYK8
jimg ->
      Array D Ix2 (Pixel cs e) -> Image r cs e
forall r ix e r'.
(Mutable r ix e, Load r' ix e) =>
Array r' ix e -> Array r ix e
compute (Array D Ix2 (Pixel cs e) -> Image r cs e)
-> (Image S (CMYK (SRGB 'NonLinear)) Pixel8
    -> Array D Ix2 (Pixel cs e))
-> Image S (CMYK (SRGB 'NonLinear)) Pixel8
-> Image r cs e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Image S (CMYK (SRGB 'NonLinear)) Pixel8 -> Array D Ix2 (Pixel cs e)
forall r' cs' e' i' cs i e.
(Source r' Ix2 (Pixel cs' e'), ColorSpace cs' i' e',
 ColorSpace cs i e) =>
Image r' cs' e' -> Image D cs e
convertImage (Image S (CMYK (SRGB 'NonLinear)) Pixel8 -> Image r cs e)
-> m (Image S (CMYK (SRGB 'NonLinear)) Pixel8) -> m (Image r cs e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
      (Image PixelCMYK8 -> m (Image S (CMYK (SRGB 'NonLinear)) Pixel8)
forall jpx cs e (m :: * -> *).
(Storable (Pixel cs e), Storable e, Pixel jpx, MonadThrow m) =>
Image jpx -> m (Image S cs e)
fromJPImageUnsafeM Image PixelCMYK8
jimg :: m (Image S (CMYK (SRGB 'NonLinear)) Word8))
    JP.ImageCMYK16 Image PixelCMYK16
jimg ->
      Array D Ix2 (Pixel cs e) -> Image r cs e
forall r ix e r'.
(Mutable r ix e, Load r' ix e) =>
Array r' ix e -> Array r ix e
compute (Array D Ix2 (Pixel cs e) -> Image r cs e)
-> (Image S (CMYK (SRGB 'NonLinear)) Pixel16
    -> Array D Ix2 (Pixel cs e))
-> Image S (CMYK (SRGB 'NonLinear)) Pixel16
-> Image r cs e
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Image S (CMYK (SRGB 'NonLinear)) Pixel16
-> Array D Ix2 (Pixel cs e)
forall r' cs' e' i' cs i e.
(Source r' Ix2 (Pixel cs' e'), ColorSpace cs' i' e',
 ColorSpace cs i e) =>
Image r' cs' e' -> Image D cs e
convertImage (Image S (CMYK (SRGB 'NonLinear)) Pixel16 -> Image r cs e)
-> m (Image S (CMYK (SRGB 'NonLinear)) Pixel16) -> m (Image r cs e)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
      (Image PixelCMYK16 -> m (Image S (CMYK (SRGB 'NonLinear)) Pixel16)
forall jpx cs e (m :: * -> *).
(Storable (Pixel cs e), Storable e, Pixel jpx, MonadThrow m) =>
Image jpx -> m (Image S cs e)
fromJPImageUnsafeM Image PixelCMYK16
jimg :: m (Image S (CMYK (SRGB 'NonLinear)) Word16))



showJP :: JP.DynamicImage -> String
showJP :: DynamicImage -> String
showJP (JP.ImageY8     Image Pixel8
_) = String
"Image S Y Word8"
showJP (JP.ImageY16    Image Pixel16
_) = String
"Image S Y Word16"
showJP (JP.ImageY32    Image Pixel32
_) = String
"Image S Y Word32"
showJP (JP.ImageYF     Image PixelF
_) = String
"Image S Y Float"
showJP (JP.ImageYA8    Image PixelYA8
_) = String
"Image S YA Word8"
showJP (JP.ImageYA16   Image PixelYA16
_) = String
"Image S YA Word16"
showJP (JP.ImageRGB8   Image PixelRGB8
_) = String
"Image S RGB Word8"
showJP (JP.ImageRGB16  Image PixelRGB16
_) = String
"Image S RGB Word16"
showJP (JP.ImageRGBF   Image PixelRGBF
_) = String
"Image S RGB Float"
showJP (JP.ImageRGBA8  Image PixelRGBA8
_) = String
"Image S RGBA Word8"
showJP (JP.ImageRGBA16 Image PixelRGBA16
_) = String
"Image S RGBA Word16"
showJP (JP.ImageYCbCr8 Image PixelYCbCr8
_) = String
"Image S YCbCr Word8"
showJP (JP.ImageCMYK8  Image PixelCMYK8
_) = String
"Image S CMYK Word8"
showJP (JP.ImageCMYK16 Image PixelCMYK16
_) = String
"Image S CMYK Word16"


-- Encoding

toJPImageUnsafe
  :: forall r cs a . (JP.Pixel a, Source r Ix2 (Pixel cs (JP.PixelBaseComponent a)),
                      ColorModel cs (JP.PixelBaseComponent a))
  => Image r cs (JP.PixelBaseComponent a)
  -> JP.Image a
toJPImageUnsafe :: Image r cs (PixelBaseComponent a) -> Image a
toJPImageUnsafe Image r cs (PixelBaseComponent a)
img = Int -> Int -> Vector (PixelBaseComponent a) -> Image a
forall a. Int -> Int -> Vector (PixelBaseComponent a) -> Image a
JP.Image Int
n Int
m (Vector (PixelBaseComponent a) -> Image a)
-> Vector (PixelBaseComponent a) -> Image a
forall a b. (a -> b) -> a -> b
$ Vector (Pixel cs (PixelBaseComponent a))
-> Vector (PixelBaseComponent a)
forall a b. (Storable a, Storable b) => Vector a -> Vector b
V.unsafeCast (Vector (Pixel cs (PixelBaseComponent a))
 -> Vector (PixelBaseComponent a))
-> Vector (Pixel cs (PixelBaseComponent a))
-> Vector (PixelBaseComponent a)
forall a b. (a -> b) -> a -> b
$ Array S Ix2 (Pixel cs (PixelBaseComponent a))
-> Vector (Pixel cs (PixelBaseComponent a))
forall ix e. Array S ix e -> Vector e
toStorableVector Array S Ix2 (Pixel cs (PixelBaseComponent a))
arrS
  where
    !arrS :: Array S Ix2 (Pixel cs (PixelBaseComponent a))
arrS = Image r cs (PixelBaseComponent a)
-> Array S Ix2 (Pixel cs (PixelBaseComponent a))
forall r ix e r'.
(Mutable r ix e, Source r' ix e) =>
Array r' ix e -> Array r ix e
computeSource Image r cs (PixelBaseComponent a)
img :: Image S cs (JP.PixelBaseComponent a)
    Sz (Int
m :. Int
n) = Image r cs (PixelBaseComponent a) -> Sz Ix2
forall r ix e. Load r ix e => Array r ix e -> Sz ix
size Image r cs (PixelBaseComponent a)
img
{-# INLINE toJPImageUnsafe #-}

toJPImageY8 :: Source r Ix2 (Pixel CM.X Word8) => Image r CM.X Word8 -> JP.Image JP.Pixel8
toJPImageY8 :: Image r X Pixel8 -> Image Pixel8
toJPImageY8 = Image r X Pixel8 -> Image Pixel8
forall r cs a.
(Pixel a, Source r Ix2 (Pixel cs (PixelBaseComponent a)),
 ColorModel cs (PixelBaseComponent a)) =>
Image r cs (PixelBaseComponent a) -> Image a
toJPImageUnsafe
{-# INLINE toJPImageY8 #-}

maybeJPImageY8 ::
     forall cs. (Typeable cs, Source S Ix2 (Pixel cs Word8))
  => Image S cs Word8
  -> Maybe (JP.Image JP.Pixel8)
maybeJPImageY8 :: Image S cs Pixel8 -> Maybe (Image Pixel8)
maybeJPImageY8 Image S cs Pixel8
img =
  [Maybe (Image Pixel8)] -> Maybe (Image Pixel8)
forall (t :: * -> *) (m :: * -> *) a.
(Foldable t, MonadPlus m) =>
t (m a) -> m a
msum
    [ (\cs :~: X
Refl -> Image S X Pixel8 -> Image Pixel8
forall r.
Source r Ix2 (Pixel X Pixel8) =>
Image r X Pixel8 -> Image Pixel8
toJPImageY8 Image S cs Pixel8
Image S X Pixel8
img) ((cs :~: X) -> Image Pixel8)
-> Maybe (cs :~: X) -> Maybe (Image Pixel8)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Maybe (cs :~: X)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (cs :~: CM.X))
    , (\cs :~: Y' SRGB
Refl -> Image S X Pixel8 -> Image Pixel8
forall r.
Source r Ix2 (Pixel X Pixel8) =>
Image r X Pixel8 -> Image Pixel8
toJPImageY8 (Image S X Pixel8 -> Image Pixel8)
-> Image S X Pixel8 -> Image Pixel8
forall a b. (a -> b) -> a -> b
$ Image S cs Pixel8 -> Array S Ix2 (Pixel (BaseModel cs) Pixel8)
forall cs e.
Array S Ix2 (Pixel cs e) -> Array S Ix2 (Pixel (BaseModel cs) e)
toImageBaseModel Image S cs Pixel8
img) ((cs :~: Y' SRGB) -> Image Pixel8)
-> Maybe (cs :~: Y' SRGB) -> Maybe (Image Pixel8)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Maybe (cs :~: Y' SRGB)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (cs :~: Y' SRGB))
    , (\cs :~: Y D65
Refl -> Image S X Pixel8 -> Image Pixel8
forall r.
Source r Ix2 (Pixel X Pixel8) =>
Image r X Pixel8 -> Image Pixel8
toJPImageY8 (Image S X Pixel8 -> Image Pixel8)
-> Image S X Pixel8 -> Image Pixel8
forall a b. (a -> b) -> a -> b
$ Image S cs Pixel8 -> Array S Ix2 (Pixel (BaseModel cs) Pixel8)
forall cs e.
Array S Ix2 (Pixel cs e) -> Array S Ix2 (Pixel (BaseModel cs) e)
toImageBaseModel Image S cs Pixel8
img) ((cs :~: Y D65) -> Image Pixel8)
-> Maybe (cs :~: Y D65) -> Maybe (Image Pixel8)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Maybe (cs :~: Y D65)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (cs :~: Y D65))
    ]
{-# INLINE maybeJPImageY8 #-}

toJPImageY16 :: Source r Ix2 (Pixel CM.X Word16) => Image r CM.X Word16 -> JP.Image JP.Pixel16
toJPImageY16 :: Image r X Pixel16 -> Image Pixel16
toJPImageY16 = Image r X Pixel16 -> Image Pixel16
forall r cs a.
(Pixel a, Source r Ix2 (Pixel cs (PixelBaseComponent a)),
 ColorModel cs (PixelBaseComponent a)) =>
Image r cs (PixelBaseComponent a) -> Image a
toJPImageUnsafe
{-# INLINE toJPImageY16 #-}



maybeJPImageY16 ::
     forall cs. (Typeable cs, Source S Ix2 (Pixel cs Word16))
  => Image S cs Word16
  -> Maybe (JP.Image JP.Pixel16)
maybeJPImageY16 :: Image S cs Pixel16 -> Maybe (Image Pixel16)
maybeJPImageY16 Image S cs Pixel16
img =
  [Maybe (Image Pixel16)] -> Maybe (Image Pixel16)
forall (t :: * -> *) (m :: * -> *) a.
(Foldable t, MonadPlus m) =>
t (m a) -> m a
msum
    [ (\cs :~: X
Refl -> Image S X Pixel16 -> Image Pixel16
forall r.
Source r Ix2 (Pixel X Pixel16) =>
Image r X Pixel16 -> Image Pixel16
toJPImageY16 Image S cs Pixel16
Image S X Pixel16
img) ((cs :~: X) -> Image Pixel16)
-> Maybe (cs :~: X) -> Maybe (Image Pixel16)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Maybe (cs :~: X)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (cs :~: CM.X))
    , (\cs :~: Y' SRGB
Refl -> Image S X Pixel16 -> Image Pixel16
forall r.
Source r Ix2 (Pixel X Pixel16) =>
Image r X Pixel16 -> Image Pixel16
toJPImageY16 (Image S X Pixel16 -> Image Pixel16)
-> Image S X Pixel16 -> Image Pixel16
forall a b. (a -> b) -> a -> b
$ Image S cs Pixel16 -> Array S Ix2 (Pixel (BaseModel cs) Pixel16)
forall cs e.
Array S Ix2 (Pixel cs e) -> Array S Ix2 (Pixel (BaseModel cs) e)
toImageBaseModel Image S cs Pixel16
img) ((cs :~: Y' SRGB) -> Image Pixel16)
-> Maybe (cs :~: Y' SRGB) -> Maybe (Image Pixel16)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Maybe (cs :~: Y' SRGB)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (cs :~: Y' SRGB))
    , (\cs :~: Y D65
Refl -> Image S X Pixel16 -> Image Pixel16
forall r.
Source r Ix2 (Pixel X Pixel16) =>
Image r X Pixel16 -> Image Pixel16
toJPImageY16 (Image S X Pixel16 -> Image Pixel16)
-> Image S X Pixel16 -> Image Pixel16
forall a b. (a -> b) -> a -> b
$ Image S cs Pixel16 -> Array S Ix2 (Pixel (BaseModel cs) Pixel16)
forall cs e.
Array S Ix2 (Pixel cs e) -> Array S Ix2 (Pixel (BaseModel cs) e)
toImageBaseModel Image S cs Pixel16
img) ((cs :~: Y D65) -> Image Pixel16)
-> Maybe (cs :~: Y D65) -> Maybe (Image Pixel16)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Maybe (cs :~: Y D65)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (cs :~: Y D65))
    ]
{-# INLINE maybeJPImageY16 #-}

toJPImageY32 :: Source r Ix2 (Pixel CM.X Word32) => Image r CM.X Word32 -> JP.Image JP.Pixel32
toJPImageY32 :: Image r X Pixel32 -> Image Pixel32
toJPImageY32 = Image r X Pixel32 -> Image Pixel32
forall r cs a.
(Pixel a, Source r Ix2 (Pixel cs (PixelBaseComponent a)),
 ColorModel cs (PixelBaseComponent a)) =>
Image r cs (PixelBaseComponent a) -> Image a
toJPImageUnsafe
{-# INLINE toJPImageY32 #-}


maybeJPImageY32 ::
     forall cs. (Typeable cs, Source S Ix2 (Pixel cs Word32))
  => Image S cs Word32
  -> Maybe (JP.Image JP.Pixel32)
maybeJPImageY32 :: Image S cs Pixel32 -> Maybe (Image Pixel32)
maybeJPImageY32 Image S cs Pixel32
img =
  [Maybe (Image Pixel32)] -> Maybe (Image Pixel32)
forall (t :: * -> *) (m :: * -> *) a.
(Foldable t, MonadPlus m) =>
t (m a) -> m a
msum
    [ (\cs :~: X
Refl -> Image S X Pixel32 -> Image Pixel32
forall r.
Source r Ix2 (Pixel X Pixel32) =>
Image r X Pixel32 -> Image Pixel32
toJPImageY32 Image S cs Pixel32
Image S X Pixel32
img) ((cs :~: X) -> Image Pixel32)
-> Maybe (cs :~: X) -> Maybe (Image Pixel32)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Maybe (cs :~: X)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (cs :~: CM.X))
    , (\cs :~: Y' SRGB
Refl -> Image S X Pixel32 -> Image Pixel32
forall r.
Source r Ix2 (Pixel X Pixel32) =>
Image r X Pixel32 -> Image Pixel32
toJPImageY32 (Image S X Pixel32 -> Image Pixel32)
-> Image S X Pixel32 -> Image Pixel32
forall a b. (a -> b) -> a -> b
$ Image S cs Pixel32 -> Array S Ix2 (Pixel (BaseModel cs) Pixel32)
forall cs e.
Array S Ix2 (Pixel cs e) -> Array S Ix2 (Pixel (BaseModel cs) e)
toImageBaseModel Image S cs Pixel32
img) ((cs :~: Y' SRGB) -> Image Pixel32)
-> Maybe (cs :~: Y' SRGB) -> Maybe (Image Pixel32)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Maybe (cs :~: Y' SRGB)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (cs :~: Y' SRGB))
    , (\cs :~: Y D65
Refl -> Image S X Pixel32 -> Image Pixel32
forall r.
Source r Ix2 (Pixel X Pixel32) =>
Image r X Pixel32 -> Image Pixel32
toJPImageY32 (Image S X Pixel32 -> Image Pixel32)
-> Image S X Pixel32 -> Image Pixel32
forall a b. (a -> b) -> a -> b
$ Image S cs Pixel32 -> Array S Ix2 (Pixel (BaseModel cs) Pixel32)
forall cs e.
Array S Ix2 (Pixel cs e) -> Array S Ix2 (Pixel (BaseModel cs) e)
toImageBaseModel Image S cs Pixel32
img) ((cs :~: Y D65) -> Image Pixel32)
-> Maybe (cs :~: Y D65) -> Maybe (Image Pixel32)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Maybe (cs :~: Y D65)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (cs :~: Y D65))
    ]
{-# INLINE maybeJPImageY32 #-}


toJPImageYF :: Source r Ix2 (Pixel CM.X Float) => Image r CM.X Float -> JP.Image JP.PixelF
toJPImageYF :: Image r X PixelF -> Image PixelF
toJPImageYF = Image r X PixelF -> Image PixelF
forall r cs a.
(Pixel a, Source r Ix2 (Pixel cs (PixelBaseComponent a)),
 ColorModel cs (PixelBaseComponent a)) =>
Image r cs (PixelBaseComponent a) -> Image a
toJPImageUnsafe
{-# INLINE toJPImageYF #-}


maybeJPImageYF ::
     forall cs. (Typeable cs, Source S Ix2 (Pixel cs Float))
  => Image S cs Float
  -> Maybe (JP.Image JP.PixelF)
maybeJPImageYF :: Image S cs PixelF -> Maybe (Image PixelF)
maybeJPImageYF Image S cs PixelF
img =
  [Maybe (Image PixelF)] -> Maybe (Image PixelF)
forall (t :: * -> *) (m :: * -> *) a.
(Foldable t, MonadPlus m) =>
t (m a) -> m a
msum
    [ (\cs :~: X
Refl -> Image S X PixelF -> Image PixelF
forall r.
Source r Ix2 (Pixel X PixelF) =>
Image r X PixelF -> Image PixelF
toJPImageYF Image S cs PixelF
Image S X PixelF
img) ((cs :~: X) -> Image PixelF)
-> Maybe (cs :~: X) -> Maybe (Image PixelF)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Maybe (cs :~: X)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (cs :~: CM.X))
    , (\cs :~: Y' SRGB
Refl -> Image S X PixelF -> Image PixelF
forall r.
Source r Ix2 (Pixel X PixelF) =>
Image r X PixelF -> Image PixelF
toJPImageYF (Image S X PixelF -> Image PixelF)
-> Image S X PixelF -> Image PixelF
forall a b. (a -> b) -> a -> b
$ Image S cs PixelF -> Array S Ix2 (Pixel (BaseModel cs) PixelF)
forall cs e.
Array S Ix2 (Pixel cs e) -> Array S Ix2 (Pixel (BaseModel cs) e)
toImageBaseModel Image S cs PixelF
img) ((cs :~: Y' SRGB) -> Image PixelF)
-> Maybe (cs :~: Y' SRGB) -> Maybe (Image PixelF)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Maybe (cs :~: Y' SRGB)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (cs :~: Y' SRGB))
    , (\cs :~: Y D65
Refl -> Image S X PixelF -> Image PixelF
forall r.
Source r Ix2 (Pixel X PixelF) =>
Image r X PixelF -> Image PixelF
toJPImageYF (Image S X PixelF -> Image PixelF)
-> Image S X PixelF -> Image PixelF
forall a b. (a -> b) -> a -> b
$ Image S cs PixelF -> Array S Ix2 (Pixel (BaseModel cs) PixelF)
forall cs e.
Array S Ix2 (Pixel cs e) -> Array S Ix2 (Pixel (BaseModel cs) e)
toImageBaseModel Image S cs PixelF
img) ((cs :~: Y D65) -> Image PixelF)
-> Maybe (cs :~: Y D65) -> Maybe (Image PixelF)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Maybe (cs :~: Y D65)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (cs :~: Y D65))
    ]
{-# INLINE maybeJPImageYF #-}


toJPImageYA8 ::
     Source r Ix2 (Pixel (Alpha CM.X) Word8) => Image r (Alpha CM.X) Word8 -> JP.Image JP.PixelYA8
toJPImageYA8 :: Image r (Alpha X) Pixel8 -> Image PixelYA8
toJPImageYA8 = Image r (Alpha X) Pixel8 -> Image PixelYA8
forall r cs a.
(Pixel a, Source r Ix2 (Pixel cs (PixelBaseComponent a)),
 ColorModel cs (PixelBaseComponent a)) =>
Image r cs (PixelBaseComponent a) -> Image a
toJPImageUnsafe
{-# INLINE toJPImageYA8 #-}

maybeJPImageYA8 ::
     forall cs. (Typeable cs, Source S Ix2 (Pixel (Alpha cs) Word8))
  => Image S (Alpha cs) Word8
  -> Maybe (JP.Image JP.PixelYA8)
maybeJPImageYA8 :: Image S (Alpha cs) Pixel8 -> Maybe (Image PixelYA8)
maybeJPImageYA8 Image S (Alpha cs) Pixel8
img =
  [Maybe (Image PixelYA8)] -> Maybe (Image PixelYA8)
forall (t :: * -> *) (m :: * -> *) a.
(Foldable t, MonadPlus m) =>
t (m a) -> m a
msum
    [ (\cs :~: X
Refl -> Image S (Alpha X) Pixel8 -> Image PixelYA8
forall r.
Source r Ix2 (Pixel (Alpha X) Pixel8) =>
Image r (Alpha X) Pixel8 -> Image PixelYA8
toJPImageYA8 Image S (Alpha cs) Pixel8
Image S (Alpha X) Pixel8
img) ((cs :~: X) -> Image PixelYA8)
-> Maybe (cs :~: X) -> Maybe (Image PixelYA8)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Maybe (cs :~: X)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (cs :~: CM.X))
    , (\cs :~: Y' SRGB
Refl -> Image S (Alpha X) Pixel8 -> Image PixelYA8
forall r.
Source r Ix2 (Pixel (Alpha X) Pixel8) =>
Image r (Alpha X) Pixel8 -> Image PixelYA8
toJPImageYA8 (Image S (Alpha X) Pixel8 -> Image PixelYA8)
-> Image S (Alpha X) Pixel8 -> Image PixelYA8
forall a b. (a -> b) -> a -> b
$ Image S (Alpha cs) Pixel8
-> Array S Ix2 (Pixel (BaseModel (Alpha cs)) Pixel8)
forall cs e.
Array S Ix2 (Pixel cs e) -> Array S Ix2 (Pixel (BaseModel cs) e)
toImageBaseModel Image S (Alpha cs) Pixel8
img) ((cs :~: Y' SRGB) -> Image PixelYA8)
-> Maybe (cs :~: Y' SRGB) -> Maybe (Image PixelYA8)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Maybe (cs :~: Y' SRGB)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (cs :~: Y' SRGB))
    , (\cs :~: Y D65
Refl -> Image S (Alpha X) Pixel8 -> Image PixelYA8
forall r.
Source r Ix2 (Pixel (Alpha X) Pixel8) =>
Image r (Alpha X) Pixel8 -> Image PixelYA8
toJPImageYA8 (Image S (Alpha X) Pixel8 -> Image PixelYA8)
-> Image S (Alpha X) Pixel8 -> Image PixelYA8
forall a b. (a -> b) -> a -> b
$ Image S (Alpha cs) Pixel8
-> Array S Ix2 (Pixel (BaseModel (Alpha cs)) Pixel8)
forall cs e.
Array S Ix2 (Pixel cs e) -> Array S Ix2 (Pixel (BaseModel cs) e)
toImageBaseModel Image S (Alpha cs) Pixel8
img) ((cs :~: Y D65) -> Image PixelYA8)
-> Maybe (cs :~: Y D65) -> Maybe (Image PixelYA8)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Maybe (cs :~: Y D65)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (cs :~: Y D65))
    ]
{-# INLINE maybeJPImageYA8 #-}


toJPImageYA16 ::
     Source r Ix2 (Pixel (Alpha CM.X) Word16)
  => Image r (Alpha CM.X) Word16
  -> JP.Image JP.PixelYA16
toJPImageYA16 :: Image r (Alpha X) Pixel16 -> Image PixelYA16
toJPImageYA16 = Image r (Alpha X) Pixel16 -> Image PixelYA16
forall r cs a.
(Pixel a, Source r Ix2 (Pixel cs (PixelBaseComponent a)),
 ColorModel cs (PixelBaseComponent a)) =>
Image r cs (PixelBaseComponent a) -> Image a
toJPImageUnsafe
{-# INLINE toJPImageYA16 #-}


maybeJPImageYA16 ::
     forall cs. (Typeable cs, Source S Ix2 (Pixel (Alpha cs) Word16))
  => Image S (Alpha cs) Word16
  -> Maybe (JP.Image JP.PixelYA16)
maybeJPImageYA16 :: Image S (Alpha cs) Pixel16 -> Maybe (Image PixelYA16)
maybeJPImageYA16 Image S (Alpha cs) Pixel16
img =
  [Maybe (Image PixelYA16)] -> Maybe (Image PixelYA16)
forall (t :: * -> *) (m :: * -> *) a.
(Foldable t, MonadPlus m) =>
t (m a) -> m a
msum
    [ (\cs :~: X
Refl -> Image S (Alpha X) Pixel16 -> Image PixelYA16
forall r.
Source r Ix2 (Pixel (Alpha X) Pixel16) =>
Image r (Alpha X) Pixel16 -> Image PixelYA16
toJPImageYA16 Image S (Alpha cs) Pixel16
Image S (Alpha X) Pixel16
img) ((cs :~: X) -> Image PixelYA16)
-> Maybe (cs :~: X) -> Maybe (Image PixelYA16)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Maybe (cs :~: X)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (cs :~: CM.X))
    , (\cs :~: Y' SRGB
Refl -> Image S (Alpha X) Pixel16 -> Image PixelYA16
forall r.
Source r Ix2 (Pixel (Alpha X) Pixel16) =>
Image r (Alpha X) Pixel16 -> Image PixelYA16
toJPImageYA16 (Image S (Alpha X) Pixel16 -> Image PixelYA16)
-> Image S (Alpha X) Pixel16 -> Image PixelYA16
forall a b. (a -> b) -> a -> b
$ Image S (Alpha cs) Pixel16
-> Array S Ix2 (Pixel (BaseModel (Alpha cs)) Pixel16)
forall cs e.
Array S Ix2 (Pixel cs e) -> Array S Ix2 (Pixel (BaseModel cs) e)
toImageBaseModel Image S (Alpha cs) Pixel16
img) ((cs :~: Y' SRGB) -> Image PixelYA16)
-> Maybe (cs :~: Y' SRGB) -> Maybe (Image PixelYA16)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Maybe (cs :~: Y' SRGB)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (cs :~: Y' SRGB))
    , (\cs :~: Y D65
Refl -> Image S (Alpha X) Pixel16 -> Image PixelYA16
forall r.
Source r Ix2 (Pixel (Alpha X) Pixel16) =>
Image r (Alpha X) Pixel16 -> Image PixelYA16
toJPImageYA16 (Image S (Alpha X) Pixel16 -> Image PixelYA16)
-> Image S (Alpha X) Pixel16 -> Image PixelYA16
forall a b. (a -> b) -> a -> b
$ Image S (Alpha cs) Pixel16
-> Array S Ix2 (Pixel (BaseModel (Alpha cs)) Pixel16)
forall cs e.
Array S Ix2 (Pixel cs e) -> Array S Ix2 (Pixel (BaseModel cs) e)
toImageBaseModel Image S (Alpha cs) Pixel16
img) ((cs :~: Y D65) -> Image PixelYA16)
-> Maybe (cs :~: Y D65) -> Maybe (Image PixelYA16)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Maybe (cs :~: Y D65)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (cs :~: Y D65))
    ]
{-# INLINE maybeJPImageYA16 #-}



toJPImageRGB8 :: Source r Ix2 (Pixel CM.RGB Word8) => Image r CM.RGB Word8 -> JP.Image JP.PixelRGB8
toJPImageRGB8 :: Image r RGB Pixel8 -> Image PixelRGB8
toJPImageRGB8 = Image r RGB Pixel8 -> Image PixelRGB8
forall r cs a.
(Pixel a, Source r Ix2 (Pixel cs (PixelBaseComponent a)),
 ColorModel cs (PixelBaseComponent a)) =>
Image r cs (PixelBaseComponent a) -> Image a
toJPImageUnsafe
{-# INLINE toJPImageRGB8 #-}


maybeJPImageRGB8 ::
     forall cs. (Typeable cs, Source S Ix2 (Pixel cs Word8))
  => Image S cs Word8
  -> Maybe (JP.Image JP.PixelRGB8)
maybeJPImageRGB8 :: Image S cs Pixel8 -> Maybe (Image PixelRGB8)
maybeJPImageRGB8 Image S cs Pixel8
img =
  [Maybe (Image PixelRGB8)] -> Maybe (Image PixelRGB8)
forall (t :: * -> *) (m :: * -> *) a.
(Foldable t, MonadPlus m) =>
t (m a) -> m a
msum
    [ (\cs :~: RGB
Refl -> Image S RGB Pixel8 -> Image PixelRGB8
forall r.
Source r Ix2 (Pixel RGB Pixel8) =>
Image r RGB Pixel8 -> Image PixelRGB8
toJPImageRGB8 Image S cs Pixel8
Image S RGB Pixel8
img) ((cs :~: RGB) -> Image PixelRGB8)
-> Maybe (cs :~: RGB) -> Maybe (Image PixelRGB8)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Maybe (cs :~: RGB)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (cs :~: CM.RGB))
    , (\cs :~: SRGB 'NonLinear
Refl -> Image S RGB Pixel8 -> Image PixelRGB8
forall r.
Source r Ix2 (Pixel RGB Pixel8) =>
Image r RGB Pixel8 -> Image PixelRGB8
toJPImageRGB8 (Image S RGB Pixel8 -> Image PixelRGB8)
-> Image S RGB Pixel8 -> Image PixelRGB8
forall a b. (a -> b) -> a -> b
$ Image S cs Pixel8 -> Array S Ix2 (Pixel (BaseModel cs) Pixel8)
forall cs e.
Array S Ix2 (Pixel cs e) -> Array S Ix2 (Pixel (BaseModel cs) e)
toImageBaseModel Image S cs Pixel8
img) ((cs :~: SRGB 'NonLinear) -> Image PixelRGB8)
-> Maybe (cs :~: SRGB 'NonLinear) -> Maybe (Image PixelRGB8)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Maybe (cs :~: SRGB 'NonLinear)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (cs :~: SRGB 'NonLinear))
    , (\cs :~: AdobeRGB 'NonLinear
Refl -> Image S RGB Pixel8 -> Image PixelRGB8
forall r.
Source r Ix2 (Pixel RGB Pixel8) =>
Image r RGB Pixel8 -> Image PixelRGB8
toJPImageRGB8 (Image S RGB Pixel8 -> Image PixelRGB8)
-> Image S RGB Pixel8 -> Image PixelRGB8
forall a b. (a -> b) -> a -> b
$ Image S cs Pixel8 -> Array S Ix2 (Pixel (BaseModel cs) Pixel8)
forall cs e.
Array S Ix2 (Pixel cs e) -> Array S Ix2 (Pixel (BaseModel cs) e)
toImageBaseModel Image S cs Pixel8
img) ((cs :~: AdobeRGB 'NonLinear) -> Image PixelRGB8)
-> Maybe (cs :~: AdobeRGB 'NonLinear) -> Maybe (Image PixelRGB8)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Maybe (cs :~: AdobeRGB 'NonLinear)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (cs :~: AdobeRGB 'NonLinear))
    ]
{-# INLINE maybeJPImageRGB8 #-}


toJPImageRGB16 ::
     Source r Ix2 (Pixel CM.RGB Word16) => Image r CM.RGB Word16 -> JP.Image JP.PixelRGB16
toJPImageRGB16 :: Image r RGB Pixel16 -> Image PixelRGB16
toJPImageRGB16 = Image r RGB Pixel16 -> Image PixelRGB16
forall r cs a.
(Pixel a, Source r Ix2 (Pixel cs (PixelBaseComponent a)),
 ColorModel cs (PixelBaseComponent a)) =>
Image r cs (PixelBaseComponent a) -> Image a
toJPImageUnsafe
{-# INLINE toJPImageRGB16 #-}

maybeJPImageRGB16 ::
     forall cs. (Typeable cs, Source S Ix2 (Pixel cs Word16))
  => Image S cs Word16
  -> Maybe (JP.Image JP.PixelRGB16)
maybeJPImageRGB16 :: Image S cs Pixel16 -> Maybe (Image PixelRGB16)
maybeJPImageRGB16 Image S cs Pixel16
img =
  [Maybe (Image PixelRGB16)] -> Maybe (Image PixelRGB16)
forall (t :: * -> *) (m :: * -> *) a.
(Foldable t, MonadPlus m) =>
t (m a) -> m a
msum
    [ (\cs :~: RGB
Refl -> Image S RGB Pixel16 -> Image PixelRGB16
forall r.
Source r Ix2 (Pixel RGB Pixel16) =>
Image r RGB Pixel16 -> Image PixelRGB16
toJPImageRGB16 Image S cs Pixel16
Image S RGB Pixel16
img) ((cs :~: RGB) -> Image PixelRGB16)
-> Maybe (cs :~: RGB) -> Maybe (Image PixelRGB16)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Maybe (cs :~: RGB)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (cs :~: CM.RGB))
    , (\cs :~: SRGB 'NonLinear
Refl -> Image S RGB Pixel16 -> Image PixelRGB16
forall r.
Source r Ix2 (Pixel RGB Pixel16) =>
Image r RGB Pixel16 -> Image PixelRGB16
toJPImageRGB16 (Image S RGB Pixel16 -> Image PixelRGB16)
-> Image S RGB Pixel16 -> Image PixelRGB16
forall a b. (a -> b) -> a -> b
$ Image S cs Pixel16 -> Array S Ix2 (Pixel (BaseModel cs) Pixel16)
forall cs e.
Array S Ix2 (Pixel cs e) -> Array S Ix2 (Pixel (BaseModel cs) e)
toImageBaseModel Image S cs Pixel16
img) ((cs :~: SRGB 'NonLinear) -> Image PixelRGB16)
-> Maybe (cs :~: SRGB 'NonLinear) -> Maybe (Image PixelRGB16)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Maybe (cs :~: SRGB 'NonLinear)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (cs :~: SRGB 'NonLinear))
    , (\cs :~: AdobeRGB 'NonLinear
Refl -> Image S RGB Pixel16 -> Image PixelRGB16
forall r.
Source r Ix2 (Pixel RGB Pixel16) =>
Image r RGB Pixel16 -> Image PixelRGB16
toJPImageRGB16 (Image S RGB Pixel16 -> Image PixelRGB16)
-> Image S RGB Pixel16 -> Image PixelRGB16
forall a b. (a -> b) -> a -> b
$ Image S cs Pixel16 -> Array S Ix2 (Pixel (BaseModel cs) Pixel16)
forall cs e.
Array S Ix2 (Pixel cs e) -> Array S Ix2 (Pixel (BaseModel cs) e)
toImageBaseModel Image S cs Pixel16
img) ((cs :~: AdobeRGB 'NonLinear) -> Image PixelRGB16)
-> Maybe (cs :~: AdobeRGB 'NonLinear) -> Maybe (Image PixelRGB16)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Maybe (cs :~: AdobeRGB 'NonLinear)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (cs :~: AdobeRGB 'NonLinear))
    ]
{-# INLINE maybeJPImageRGB16 #-}


toJPImageRGBF :: Source r Ix2 (Pixel CM.RGB Float) => Image r CM.RGB Float -> JP.Image JP.PixelRGBF
toJPImageRGBF :: Image r RGB PixelF -> Image PixelRGBF
toJPImageRGBF = Image r RGB PixelF -> Image PixelRGBF
forall r cs a.
(Pixel a, Source r Ix2 (Pixel cs (PixelBaseComponent a)),
 ColorModel cs (PixelBaseComponent a)) =>
Image r cs (PixelBaseComponent a) -> Image a
toJPImageUnsafe
{-# INLINE toJPImageRGBF #-}

maybeJPImageRGBF ::
     forall cs. (Typeable cs, Source S Ix2 (Pixel cs Float))
  => Image S cs Float
  -> Maybe (JP.Image JP.PixelRGBF)
maybeJPImageRGBF :: Image S cs PixelF -> Maybe (Image PixelRGBF)
maybeJPImageRGBF Image S cs PixelF
img =
  [Maybe (Image PixelRGBF)] -> Maybe (Image PixelRGBF)
forall (t :: * -> *) (m :: * -> *) a.
(Foldable t, MonadPlus m) =>
t (m a) -> m a
msum
    [ (\cs :~: RGB
Refl -> Image S RGB PixelF -> Image PixelRGBF
forall r.
Source r Ix2 (Pixel RGB PixelF) =>
Image r RGB PixelF -> Image PixelRGBF
toJPImageRGBF Image S cs PixelF
Image S RGB PixelF
img) ((cs :~: RGB) -> Image PixelRGBF)
-> Maybe (cs :~: RGB) -> Maybe (Image PixelRGBF)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Maybe (cs :~: RGB)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (cs :~: CM.RGB))
    , (\cs :~: SRGB 'NonLinear
Refl -> Image S RGB PixelF -> Image PixelRGBF
forall r.
Source r Ix2 (Pixel RGB PixelF) =>
Image r RGB PixelF -> Image PixelRGBF
toJPImageRGBF (Image S RGB PixelF -> Image PixelRGBF)
-> Image S RGB PixelF -> Image PixelRGBF
forall a b. (a -> b) -> a -> b
$ Image S cs PixelF -> Array S Ix2 (Pixel (BaseModel cs) PixelF)
forall cs e.
Array S Ix2 (Pixel cs e) -> Array S Ix2 (Pixel (BaseModel cs) e)
toImageBaseModel Image S cs PixelF
img) ((cs :~: SRGB 'NonLinear) -> Image PixelRGBF)
-> Maybe (cs :~: SRGB 'NonLinear) -> Maybe (Image PixelRGBF)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Maybe (cs :~: SRGB 'NonLinear)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (cs :~: SRGB 'NonLinear))
    , (\cs :~: AdobeRGB 'NonLinear
Refl -> Image S RGB PixelF -> Image PixelRGBF
forall r.
Source r Ix2 (Pixel RGB PixelF) =>
Image r RGB PixelF -> Image PixelRGBF
toJPImageRGBF (Image S RGB PixelF -> Image PixelRGBF)
-> Image S RGB PixelF -> Image PixelRGBF
forall a b. (a -> b) -> a -> b
$ Image S cs PixelF -> Array S Ix2 (Pixel (BaseModel cs) PixelF)
forall cs e.
Array S Ix2 (Pixel cs e) -> Array S Ix2 (Pixel (BaseModel cs) e)
toImageBaseModel Image S cs PixelF
img) ((cs :~: AdobeRGB 'NonLinear) -> Image PixelRGBF)
-> Maybe (cs :~: AdobeRGB 'NonLinear) -> Maybe (Image PixelRGBF)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Maybe (cs :~: AdobeRGB 'NonLinear)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (cs :~: AdobeRGB 'NonLinear))
    ]
{-# INLINE maybeJPImageRGBF #-}


toJPImageRGBA8 ::
     Source r Ix2 (Pixel (Alpha CM.RGB) Word8)
  => Image r (Alpha CM.RGB) Word8
  -> JP.Image JP.PixelRGBA8
toJPImageRGBA8 :: Image r (Alpha RGB) Pixel8 -> Image PixelRGBA8
toJPImageRGBA8 = Image r (Alpha RGB) Pixel8 -> Image PixelRGBA8
forall r cs a.
(Pixel a, Source r Ix2 (Pixel cs (PixelBaseComponent a)),
 ColorModel cs (PixelBaseComponent a)) =>
Image r cs (PixelBaseComponent a) -> Image a
toJPImageUnsafe
{-# INLINE toJPImageRGBA8 #-}

maybeJPImageRGBA8 ::
     forall cs. (Typeable cs, Source S Ix2 (Pixel (Alpha cs) Word8))
  => Image S (Alpha cs) Word8
  -> Maybe (JP.Image JP.PixelRGBA8)
maybeJPImageRGBA8 :: Image S (Alpha cs) Pixel8 -> Maybe (Image PixelRGBA8)
maybeJPImageRGBA8 Image S (Alpha cs) Pixel8
img =
  [Maybe (Image PixelRGBA8)] -> Maybe (Image PixelRGBA8)
forall (t :: * -> *) (m :: * -> *) a.
(Foldable t, MonadPlus m) =>
t (m a) -> m a
msum
    [ (\cs :~: RGB
Refl -> Image S (Alpha RGB) Pixel8 -> Image PixelRGBA8
forall r.
Source r Ix2 (Pixel (Alpha RGB) Pixel8) =>
Image r (Alpha RGB) Pixel8 -> Image PixelRGBA8
toJPImageRGBA8 Image S (Alpha cs) Pixel8
Image S (Alpha RGB) Pixel8
img) ((cs :~: RGB) -> Image PixelRGBA8)
-> Maybe (cs :~: RGB) -> Maybe (Image PixelRGBA8)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Maybe (cs :~: RGB)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (cs :~: CM.RGB))
    , (\cs :~: SRGB 'NonLinear
Refl -> Image S (Alpha RGB) Pixel8 -> Image PixelRGBA8
forall r.
Source r Ix2 (Pixel (Alpha RGB) Pixel8) =>
Image r (Alpha RGB) Pixel8 -> Image PixelRGBA8
toJPImageRGBA8 (Image S (Alpha RGB) Pixel8 -> Image PixelRGBA8)
-> Image S (Alpha RGB) Pixel8 -> Image PixelRGBA8
forall a b. (a -> b) -> a -> b
$ Image S (Alpha cs) Pixel8
-> Array S Ix2 (Pixel (BaseModel (Alpha cs)) Pixel8)
forall cs e.
Array S Ix2 (Pixel cs e) -> Array S Ix2 (Pixel (BaseModel cs) e)
toImageBaseModel Image S (Alpha cs) Pixel8
img) ((cs :~: SRGB 'NonLinear) -> Image PixelRGBA8)
-> Maybe (cs :~: SRGB 'NonLinear) -> Maybe (Image PixelRGBA8)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Maybe (cs :~: SRGB 'NonLinear)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (cs :~: SRGB 'NonLinear))
    , (\cs :~: AdobeRGB 'NonLinear
Refl -> Image S (Alpha RGB) Pixel8 -> Image PixelRGBA8
forall r.
Source r Ix2 (Pixel (Alpha RGB) Pixel8) =>
Image r (Alpha RGB) Pixel8 -> Image PixelRGBA8
toJPImageRGBA8 (Image S (Alpha RGB) Pixel8 -> Image PixelRGBA8)
-> Image S (Alpha RGB) Pixel8 -> Image PixelRGBA8
forall a b. (a -> b) -> a -> b
$ Image S (Alpha cs) Pixel8
-> Array S Ix2 (Pixel (BaseModel (Alpha cs)) Pixel8)
forall cs e.
Array S Ix2 (Pixel cs e) -> Array S Ix2 (Pixel (BaseModel cs) e)
toImageBaseModel Image S (Alpha cs) Pixel8
img) ((cs :~: AdobeRGB 'NonLinear) -> Image PixelRGBA8)
-> Maybe (cs :~: AdobeRGB 'NonLinear) -> Maybe (Image PixelRGBA8)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
      (Maybe (cs :~: AdobeRGB 'NonLinear)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (cs :~: AdobeRGB 'NonLinear))
    ]
{-# INLINE maybeJPImageRGBA8 #-}


toJPImageRGBA16 ::
     Source r Ix2 (Pixel (Alpha CM.RGB) Word16)
  => Image r (Alpha CM.RGB) Word16
  -> JP.Image JP.PixelRGBA16
toJPImageRGBA16 :: Image r (Alpha RGB) Pixel16 -> Image PixelRGBA16
toJPImageRGBA16 = Image r (Alpha RGB) Pixel16 -> Image PixelRGBA16
forall r cs a.
(Pixel a, Source r Ix2 (Pixel cs (PixelBaseComponent a)),
 ColorModel cs (PixelBaseComponent a)) =>
Image r cs (PixelBaseComponent a) -> Image a
toJPImageUnsafe
{-# INLINE toJPImageRGBA16 #-}

maybeJPImageRGBA16 ::
     forall cs. (Typeable cs, Source S Ix2 (Pixel (Alpha cs) Word16))
  => Image S (Alpha cs) Word16
  -> Maybe (JP.Image JP.PixelRGBA16)
maybeJPImageRGBA16 :: Image S (Alpha cs) Pixel16 -> Maybe (Image PixelRGBA16)
maybeJPImageRGBA16 Image S (Alpha cs) Pixel16
img =
  [Maybe (Image PixelRGBA16)] -> Maybe (Image PixelRGBA16)
forall (t :: * -> *) (m :: * -> *) a.
(Foldable t, MonadPlus m) =>
t (m a) -> m a
msum
    [ (\cs :~: RGB
Refl -> Image S (Alpha RGB) Pixel16 -> Image PixelRGBA16
forall r.
Source r Ix2 (Pixel (Alpha RGB) Pixel16) =>
Image r (Alpha RGB) Pixel16 -> Image PixelRGBA16
toJPImageRGBA16 Image S (Alpha cs) Pixel16
Image S (Alpha RGB) Pixel16
img) ((cs :~: RGB) -> Image PixelRGBA16)
-> Maybe (cs :~: RGB) -> Maybe (Image PixelRGBA16)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Maybe (cs :~: RGB)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (cs :~: CM.RGB))
    , (\cs :~: SRGB 'NonLinear
Refl -> Image S (Alpha RGB) Pixel16 -> Image PixelRGBA16
forall r.
Source r Ix2 (Pixel (Alpha RGB) Pixel16) =>
Image r (Alpha RGB) Pixel16 -> Image PixelRGBA16
toJPImageRGBA16 (Image S (Alpha RGB) Pixel16 -> Image PixelRGBA16)
-> Image S (Alpha RGB) Pixel16 -> Image PixelRGBA16
forall a b. (a -> b) -> a -> b
$ Image S (Alpha cs) Pixel16
-> Array S Ix2 (Pixel (BaseModel (Alpha cs)) Pixel16)
forall cs e.
Array S Ix2 (Pixel cs e) -> Array S Ix2 (Pixel (BaseModel cs) e)
toImageBaseModel Image S (Alpha cs) Pixel16
img) ((cs :~: SRGB 'NonLinear) -> Image PixelRGBA16)
-> Maybe (cs :~: SRGB 'NonLinear) -> Maybe (Image PixelRGBA16)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
      (Maybe (cs :~: SRGB 'NonLinear)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (cs :~: SRGB 'NonLinear))
    , (\cs :~: AdobeRGB 'NonLinear
Refl -> Image S (Alpha RGB) Pixel16 -> Image PixelRGBA16
forall r.
Source r Ix2 (Pixel (Alpha RGB) Pixel16) =>
Image r (Alpha RGB) Pixel16 -> Image PixelRGBA16
toJPImageRGBA16 (Image S (Alpha RGB) Pixel16 -> Image PixelRGBA16)
-> Image S (Alpha RGB) Pixel16 -> Image PixelRGBA16
forall a b. (a -> b) -> a -> b
$ Image S (Alpha cs) Pixel16
-> Array S Ix2 (Pixel (BaseModel (Alpha cs)) Pixel16)
forall cs e.
Array S Ix2 (Pixel cs e) -> Array S Ix2 (Pixel (BaseModel cs) e)
toImageBaseModel Image S (Alpha cs) Pixel16
img) ((cs :~: AdobeRGB 'NonLinear) -> Image PixelRGBA16)
-> Maybe (cs :~: AdobeRGB 'NonLinear) -> Maybe (Image PixelRGBA16)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
      (Maybe (cs :~: AdobeRGB 'NonLinear)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (cs :~: AdobeRGB 'NonLinear))
    ]
{-# INLINE maybeJPImageRGBA16 #-}

toJPImageYCbCr8 ::
     Source r Ix2 (Pixel CM.YCbCr Word8) => Image r CM.YCbCr Word8 -> JP.Image JP.PixelYCbCr8
toJPImageYCbCr8 :: Image r YCbCr Pixel8 -> Image PixelYCbCr8
toJPImageYCbCr8 = Image r YCbCr Pixel8 -> Image PixelYCbCr8
forall r cs a.
(Pixel a, Source r Ix2 (Pixel cs (PixelBaseComponent a)),
 ColorModel cs (PixelBaseComponent a)) =>
Image r cs (PixelBaseComponent a) -> Image a
toJPImageUnsafe
{-# INLINE toJPImageYCbCr8 #-}


maybeJPImageYCbCr8 ::
     forall cs. (Typeable cs, Source S Ix2 (Pixel cs Word8))
  => Image S cs Word8
  -> Maybe (JP.Image JP.PixelYCbCr8)
maybeJPImageYCbCr8 :: Image S cs Pixel8 -> Maybe (Image PixelYCbCr8)
maybeJPImageYCbCr8 Image S cs Pixel8
img =
  [Maybe (Image PixelYCbCr8)] -> Maybe (Image PixelYCbCr8)
forall (t :: * -> *) (m :: * -> *) a.
(Foldable t, MonadPlus m) =>
t (m a) -> m a
msum
    [ (\cs :~: YCbCr
Refl -> Image S YCbCr Pixel8 -> Image PixelYCbCr8
forall r.
Source r Ix2 (Pixel YCbCr Pixel8) =>
Image r YCbCr Pixel8 -> Image PixelYCbCr8
toJPImageYCbCr8 Image S cs Pixel8
Image S YCbCr Pixel8
img) ((cs :~: YCbCr) -> Image PixelYCbCr8)
-> Maybe (cs :~: YCbCr) -> Maybe (Image PixelYCbCr8)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Maybe (cs :~: YCbCr)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (cs :~: CM.YCbCr))
    , (\cs :~: Y'CbCr SRGB
Refl -> Image S YCbCr Pixel8 -> Image PixelYCbCr8
forall r.
Source r Ix2 (Pixel YCbCr Pixel8) =>
Image r YCbCr Pixel8 -> Image PixelYCbCr8
toJPImageYCbCr8 (Image S YCbCr Pixel8 -> Image PixelYCbCr8)
-> Image S YCbCr Pixel8 -> Image PixelYCbCr8
forall a b. (a -> b) -> a -> b
$ Image S cs Pixel8 -> Array S Ix2 (Pixel (BaseModel cs) Pixel8)
forall cs e.
Array S Ix2 (Pixel cs e) -> Array S Ix2 (Pixel (BaseModel cs) e)
toImageBaseModel Image S cs Pixel8
img) ((cs :~: Y'CbCr SRGB) -> Image PixelYCbCr8)
-> Maybe (cs :~: Y'CbCr SRGB) -> Maybe (Image PixelYCbCr8)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Maybe (cs :~: Y'CbCr SRGB)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (cs :~: Y'CbCr SRGB))
    --, (\Refl -> toJPImageYCbCr8 $ toImageBaseModel img) <$> (eqT :: Maybe (cs :~: Y'CbCr AdobeRGB)))
    ]
{-# INLINE maybeJPImageYCbCr8 #-}


toJPImageCMYK8 ::
     Source r Ix2 (Pixel CM.CMYK Word8) => Image r CM.CMYK Word8 -> JP.Image JP.PixelCMYK8
toJPImageCMYK8 :: Image r CMYK Pixel8 -> Image PixelCMYK8
toJPImageCMYK8 = Image r CMYK Pixel8 -> Image PixelCMYK8
forall r cs a.
(Pixel a, Source r Ix2 (Pixel cs (PixelBaseComponent a)),
 ColorModel cs (PixelBaseComponent a)) =>
Image r cs (PixelBaseComponent a) -> Image a
toJPImageUnsafe
{-# INLINE toJPImageCMYK8 #-}


maybeJPImageCMYK8 ::
     forall cs. (Typeable cs, Source S Ix2 (Pixel cs Word8))
  => Image S cs Word8
  -> Maybe (JP.Image JP.PixelCMYK8)
maybeJPImageCMYK8 :: Image S cs Pixel8 -> Maybe (Image PixelCMYK8)
maybeJPImageCMYK8 Image S cs Pixel8
img =
  [Maybe (Image PixelCMYK8)] -> Maybe (Image PixelCMYK8)
forall (t :: * -> *) (m :: * -> *) a.
(Foldable t, MonadPlus m) =>
t (m a) -> m a
msum
    [ (\cs :~: CMYK
Refl -> Image S CMYK Pixel8 -> Image PixelCMYK8
forall r.
Source r Ix2 (Pixel CMYK Pixel8) =>
Image r CMYK Pixel8 -> Image PixelCMYK8
toJPImageCMYK8 Image S cs Pixel8
Image S CMYK Pixel8
img) ((cs :~: CMYK) -> Image PixelCMYK8)
-> Maybe (cs :~: CMYK) -> Maybe (Image PixelCMYK8)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Maybe (cs :~: CMYK)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (cs :~: CM.CMYK))
    , (\cs :~: CMYK (SRGB 'NonLinear)
Refl -> Image S CMYK Pixel8 -> Image PixelCMYK8
forall r.
Source r Ix2 (Pixel CMYK Pixel8) =>
Image r CMYK Pixel8 -> Image PixelCMYK8
toJPImageCMYK8 (Image S CMYK Pixel8 -> Image PixelCMYK8)
-> Image S CMYK Pixel8 -> Image PixelCMYK8
forall a b. (a -> b) -> a -> b
$ Image S cs Pixel8 -> Array S Ix2 (Pixel (BaseModel cs) Pixel8)
forall cs e.
Array S Ix2 (Pixel cs e) -> Array S Ix2 (Pixel (BaseModel cs) e)
toImageBaseModel Image S cs Pixel8
img) ((cs :~: CMYK (SRGB 'NonLinear)) -> Image PixelCMYK8)
-> Maybe (cs :~: CMYK (SRGB 'NonLinear))
-> Maybe (Image PixelCMYK8)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
      (Maybe (cs :~: CMYK (SRGB 'NonLinear))
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (cs :~: CMYK (SRGB 'NonLinear)))
    , (\cs :~: CMYK (AdobeRGB 'NonLinear)
Refl -> Image S CMYK Pixel8 -> Image PixelCMYK8
forall r.
Source r Ix2 (Pixel CMYK Pixel8) =>
Image r CMYK Pixel8 -> Image PixelCMYK8
toJPImageCMYK8 (Image S CMYK Pixel8 -> Image PixelCMYK8)
-> Image S CMYK Pixel8 -> Image PixelCMYK8
forall a b. (a -> b) -> a -> b
$ Image S cs Pixel8 -> Array S Ix2 (Pixel (BaseModel cs) Pixel8)
forall cs e.
Array S Ix2 (Pixel cs e) -> Array S Ix2 (Pixel (BaseModel cs) e)
toImageBaseModel Image S cs Pixel8
img) ((cs :~: CMYK (AdobeRGB 'NonLinear)) -> Image PixelCMYK8)
-> Maybe (cs :~: CMYK (AdobeRGB 'NonLinear))
-> Maybe (Image PixelCMYK8)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
      (Maybe (cs :~: CMYK (AdobeRGB 'NonLinear))
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (cs :~: CMYK (AdobeRGB 'NonLinear)))
    ]
{-# INLINE maybeJPImageCMYK8 #-}


toJPImageCMYK16 ::
     Source r Ix2 (Pixel CM.CMYK Word16) => Image r CM.CMYK Word16 -> JP.Image JP.PixelCMYK16
toJPImageCMYK16 :: Image r CMYK Pixel16 -> Image PixelCMYK16
toJPImageCMYK16 = Image r CMYK Pixel16 -> Image PixelCMYK16
forall r cs a.
(Pixel a, Source r Ix2 (Pixel cs (PixelBaseComponent a)),
 ColorModel cs (PixelBaseComponent a)) =>
Image r cs (PixelBaseComponent a) -> Image a
toJPImageUnsafe
{-# INLINE toJPImageCMYK16 #-}


maybeJPImageCMYK16 ::
     forall cs. (Typeable cs, Source S Ix2 (Pixel cs Word16))
  => Image S cs Word16
  -> Maybe (JP.Image JP.PixelCMYK16)
maybeJPImageCMYK16 :: Image S cs Pixel16 -> Maybe (Image PixelCMYK16)
maybeJPImageCMYK16 Image S cs Pixel16
img =
  [Maybe (Image PixelCMYK16)] -> Maybe (Image PixelCMYK16)
forall (t :: * -> *) (m :: * -> *) a.
(Foldable t, MonadPlus m) =>
t (m a) -> m a
msum
    [ (\cs :~: CMYK
Refl -> Image S CMYK Pixel16 -> Image PixelCMYK16
forall r.
Source r Ix2 (Pixel CMYK Pixel16) =>
Image r CMYK Pixel16 -> Image PixelCMYK16
toJPImageCMYK16 Image S cs Pixel16
Image S CMYK Pixel16
img) ((cs :~: CMYK) -> Image PixelCMYK16)
-> Maybe (cs :~: CMYK) -> Maybe (Image PixelCMYK16)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Maybe (cs :~: CMYK)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (cs :~: CM.CMYK))
    , (\cs :~: CMYK (SRGB 'NonLinear)
Refl -> Image S CMYK Pixel16 -> Image PixelCMYK16
forall r.
Source r Ix2 (Pixel CMYK Pixel16) =>
Image r CMYK Pixel16 -> Image PixelCMYK16
toJPImageCMYK16 (Image S CMYK Pixel16 -> Image PixelCMYK16)
-> Image S CMYK Pixel16 -> Image PixelCMYK16
forall a b. (a -> b) -> a -> b
$ Image S cs Pixel16 -> Array S Ix2 (Pixel (BaseModel cs) Pixel16)
forall cs e.
Array S Ix2 (Pixel cs e) -> Array S Ix2 (Pixel (BaseModel cs) e)
toImageBaseModel Image S cs Pixel16
img) ((cs :~: CMYK (SRGB 'NonLinear)) -> Image PixelCMYK16)
-> Maybe (cs :~: CMYK (SRGB 'NonLinear))
-> Maybe (Image PixelCMYK16)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
      (Maybe (cs :~: CMYK (SRGB 'NonLinear))
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (cs :~: CMYK (SRGB 'NonLinear)))
    , (\cs :~: CMYK (AdobeRGB 'NonLinear)
Refl -> Image S CMYK Pixel16 -> Image PixelCMYK16
forall r.
Source r Ix2 (Pixel CMYK Pixel16) =>
Image r CMYK Pixel16 -> Image PixelCMYK16
toJPImageCMYK16 (Image S CMYK Pixel16 -> Image PixelCMYK16)
-> Image S CMYK Pixel16 -> Image PixelCMYK16
forall a b. (a -> b) -> a -> b
$ Image S cs Pixel16 -> Array S Ix2 (Pixel (BaseModel cs) Pixel16)
forall cs e.
Array S Ix2 (Pixel cs e) -> Array S Ix2 (Pixel (BaseModel cs) e)
toImageBaseModel Image S cs Pixel16
img) ((cs :~: CMYK (AdobeRGB 'NonLinear)) -> Image PixelCMYK16)
-> Maybe (cs :~: CMYK (AdobeRGB 'NonLinear))
-> Maybe (Image PixelCMYK16)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
      (Maybe (cs :~: CMYK (AdobeRGB 'NonLinear))
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT :: Maybe (cs :~: CMYK (AdobeRGB 'NonLinear)))
    ]
{-# INLINE maybeJPImageCMYK16 #-}


-- General decoding and helper functions

fromJPImageUnsafeM ::
     forall jpx cs e m. (Storable (Pixel cs e), Storable e, JP.Pixel jpx, MonadThrow m)
  => JP.Image jpx
  -> m (Image S cs e)
fromJPImageUnsafeM :: Image jpx -> m (Image S cs e)
fromJPImageUnsafeM (JP.Image Int
n Int
m !Vector (PixelBaseComponent jpx)
v) = do
  let numberOfComponentsFromSize :: Int
numberOfComponentsFromSize = Pixel cs e -> Int
forall a. Storable a => a -> Int
sizeOf (Pixel cs e
forall a. HasCallStack => a
undefined :: Pixel cs e) Int -> Int -> Int
forall a. Integral a => a -> a -> a
`div` e -> Int
forall a. Storable a => a -> Int
sizeOf (e
forall a. HasCallStack => a
undefined :: e)
      numComponentsPerPixel :: Int
numComponentsPerPixel = jpx -> Int
forall a. Pixel a => a -> Int
JP.componentCount (jpx
forall a. HasCallStack => a
undefined :: jpx)
  Bool -> m () -> m ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (Int
numComponentsPerPixel Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
numberOfComponentsFromSize) (m () -> m ()) -> m () -> m ()
forall a b. (a -> b) -> a -> b
$
    ConvertError -> m ()
forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM (ConvertError -> m ()) -> ConvertError -> m ()
forall a b. (a -> b) -> a -> b
$ String -> ConvertError
ConvertError (String -> ConvertError) -> String -> ConvertError
forall a b. (a -> b) -> a -> b
$
    [String] -> String
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat
      [ String
"Mismatched sizes between JuicyPixels: "
      , Int -> String
forall a. Show a => a -> String
show Int
numComponentsPerPixel
      , String
" and massiv: "
      , Int -> String
forall a. Show a => a -> String
show Int
numberOfComponentsFromSize
      ]
  Bool -> m (Image S cs e) -> m (Image S cs e)
forall a. HasCallStack => Bool -> a -> a
assert (Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
m Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
numComponentsPerPixel Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Vector (PixelBaseComponent jpx) -> Int
forall a. Storable a => Vector a -> Int
V.length Vector (PixelBaseComponent jpx)
v) (m (Image S cs e) -> m (Image S cs e))
-> m (Image S cs e) -> m (Image S cs e)
forall a b. (a -> b) -> a -> b
$
    Sz Ix2 -> Vector (PixelBaseComponent jpx) -> m (Image S cs e)
forall (m :: * -> *) ix a b.
(MonadThrow m, Index ix, Storable a, Storable b) =>
Sz ix -> Vector a -> m (Array S ix b)
unsafeFromStorableVectorM (Ix2 -> Sz Ix2
forall ix. Index ix => ix -> Sz ix
Sz (Int
m Int -> Int -> Ix2
:. Int
n)) Vector (PixelBaseComponent jpx)
v


-- Conversion to sRGB color space based color models

toYCbCr8 :: forall cs i e . ColorSpace cs i e => Pixel cs e -> Pixel CM.YCbCr Word8
toYCbCr8 :: Pixel cs e -> Pixel YCbCr Pixel8
toYCbCr8 = Pixel (Y'CbCr SRGB) Pixel8 -> Pixel YCbCr Pixel8
forall k cs (i :: k) e.
ColorSpace cs i e =>
Pixel cs e -> Pixel (BaseModel cs) e
toPixelBaseModel (Pixel (Y'CbCr SRGB) Pixel8 -> Pixel YCbCr Pixel8)
-> (Pixel cs e -> Pixel (Y'CbCr SRGB) Pixel8)
-> Pixel cs e
-> Pixel YCbCr Pixel8
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Pixel cs e -> Pixel (Y'CbCr SRGB) Pixel8
forall k1 k2 cs (i :: k1) e cs' (i' :: k2) e'.
(ColorSpace cs' i' e', ColorSpace cs i e) =>
Pixel cs' e' -> Pixel cs e
convertPixel :: Pixel cs e -> Pixel (Y'CbCr SRGB) Word8)

toCMYK8 :: forall cs i e . ColorSpace cs i e => Pixel cs e -> Pixel CM.CMYK Word8
toCMYK8 :: Pixel cs e -> Pixel CMYK Pixel8
toCMYK8 = Pixel (CMYK (SRGB 'NonLinear)) Pixel8 -> Pixel CMYK Pixel8
forall k cs (i :: k) e.
ColorSpace cs i e =>
Pixel cs e -> Pixel (BaseModel cs) e
toPixelBaseModel (Pixel (CMYK (SRGB 'NonLinear)) Pixel8 -> Pixel CMYK Pixel8)
-> (Pixel cs e -> Pixel (CMYK (SRGB 'NonLinear)) Pixel8)
-> Pixel cs e
-> Pixel CMYK Pixel8
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Pixel cs e -> Pixel (CMYK (SRGB 'NonLinear)) Pixel8
forall k1 k2 cs (i :: k1) e cs' (i' :: k2) e'.
(ColorSpace cs' i' e', ColorSpace cs i e) =>
Pixel cs' e' -> Pixel cs e
convertPixel :: Pixel cs e -> Pixel (CMYK (SRGB 'NonLinear)) Word8)

toCMYK16 :: forall cs i e . ColorSpace cs i e => Pixel cs e -> Pixel CM.CMYK Word16
toCMYK16 :: Pixel cs e -> Pixel CMYK Pixel16
toCMYK16 = Pixel (CMYK (SRGB 'NonLinear)) Pixel16 -> Pixel CMYK Pixel16
forall k cs (i :: k) e.
ColorSpace cs i e =>
Pixel cs e -> Pixel (BaseModel cs) e
toPixelBaseModel (Pixel (CMYK (SRGB 'NonLinear)) Pixel16 -> Pixel CMYK Pixel16)
-> (Pixel cs e -> Pixel (CMYK (SRGB 'NonLinear)) Pixel16)
-> Pixel cs e
-> Pixel CMYK Pixel16
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Pixel cs e -> Pixel (CMYK (SRGB 'NonLinear)) Pixel16
forall k1 k2 cs (i :: k1) e cs' (i' :: k2) e'.
(ColorSpace cs' i' e', ColorSpace cs i e) =>
Pixel cs' e' -> Pixel cs e
convertPixel :: Pixel cs e -> Pixel (CMYK (SRGB 'NonLinear)) Word16)

toSRGB8 :: forall cs i e . ColorSpace cs i e => Pixel cs e -> Pixel CM.RGB Word8
toSRGB8 :: Pixel cs e -> Pixel RGB Pixel8
toSRGB8 = Pixel (SRGB 'NonLinear) Pixel8 -> Pixel RGB Pixel8
forall k cs (i :: k) e.
ColorSpace cs i e =>
Pixel cs e -> Pixel (BaseModel cs) e
toPixelBaseModel (Pixel (SRGB 'NonLinear) Pixel8 -> Pixel RGB Pixel8)
-> (Pixel cs e -> Pixel (SRGB 'NonLinear) Pixel8)
-> Pixel cs e
-> Pixel RGB Pixel8
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Pixel cs e -> Pixel (SRGB 'NonLinear) Pixel8
forall k1 k2 cs (i :: k1) e cs' (i' :: k2) e'.
(ColorSpace cs' i' e', ColorSpace cs i e) =>
Pixel cs' e' -> Pixel cs e
convertPixel :: Pixel cs e -> Pixel (SRGB 'NonLinear) Word8)

toSRGB16 :: forall cs i e . ColorSpace cs i e => Pixel cs e -> Pixel CM.RGB Word16
toSRGB16 :: Pixel cs e -> Pixel RGB Pixel16
toSRGB16 = Pixel (SRGB 'NonLinear) Pixel16 -> Pixel RGB Pixel16
forall k cs (i :: k) e.
ColorSpace cs i e =>
Pixel cs e -> Pixel (BaseModel cs) e
toPixelBaseModel (Pixel (SRGB 'NonLinear) Pixel16 -> Pixel RGB Pixel16)
-> (Pixel cs e -> Pixel (SRGB 'NonLinear) Pixel16)
-> Pixel cs e
-> Pixel RGB Pixel16
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Pixel cs e -> Pixel (SRGB 'NonLinear) Pixel16
forall k1 k2 cs (i :: k1) e cs' (i' :: k2) e'.
(ColorSpace cs' i' e', ColorSpace cs i e) =>
Pixel cs' e' -> Pixel cs e
convertPixel :: Pixel cs e -> Pixel (SRGB 'NonLinear) Word16)

toSRGBA8 :: forall cs i e . ColorSpace cs i e => Pixel cs e -> Pixel (Alpha CM.RGB) Word8
toSRGBA8 :: Pixel cs e -> Pixel (Alpha RGB) Pixel8
toSRGBA8 = Pixel (Alpha (SRGB 'NonLinear)) Pixel8 -> Pixel (Alpha RGB) Pixel8
forall k cs (i :: k) e.
ColorSpace cs i e =>
Pixel cs e -> Pixel (BaseModel cs) e
toPixelBaseModel (Pixel (Alpha (SRGB 'NonLinear)) Pixel8
 -> Pixel (Alpha RGB) Pixel8)
-> (Pixel cs e -> Pixel (Alpha (SRGB 'NonLinear)) Pixel8)
-> Pixel cs e
-> Pixel (Alpha RGB) Pixel8
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Pixel cs e -> Pixel (Alpha (SRGB 'NonLinear)) Pixel8
forall k1 k2 cs (i :: k1) e cs' (i' :: k2) e'.
(ColorSpace cs' i' e', ColorSpace cs i e) =>
Pixel cs' e' -> Pixel cs e
convertPixel :: Pixel cs e -> Pixel (Alpha (SRGB 'NonLinear)) Word8)

toSRGBA16 :: forall cs i e . ColorSpace cs i e => Pixel cs e -> Pixel (Alpha CM.RGB) Word16
toSRGBA16 :: Pixel cs e -> Pixel (Alpha RGB) Pixel16
toSRGBA16 = Pixel (Alpha (SRGB 'NonLinear)) Pixel16
-> Pixel (Alpha RGB) Pixel16
forall k cs (i :: k) e.
ColorSpace cs i e =>
Pixel cs e -> Pixel (BaseModel cs) e
toPixelBaseModel (Pixel (Alpha (SRGB 'NonLinear)) Pixel16
 -> Pixel (Alpha RGB) Pixel16)
-> (Pixel cs e -> Pixel (Alpha (SRGB 'NonLinear)) Pixel16)
-> Pixel cs e
-> Pixel (Alpha RGB) Pixel16
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Pixel cs e -> Pixel (Alpha (SRGB 'NonLinear)) Pixel16
forall k1 k2 cs (i :: k1) e cs' (i' :: k2) e'.
(ColorSpace cs' i' e', ColorSpace cs i e) =>
Pixel cs' e' -> Pixel cs e
convertPixel :: Pixel cs e -> Pixel (Alpha (SRGB 'NonLinear)) Word16)