-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Picture loading/serialization (in png, jpeg, bitmap, gif, tga, tiff and radiance) -- -- -- This library can load and store images in PNG,Bitmap, Jpeg, Radiance, -- Tiff and Gif images. @package JuicyPixels @version 3.2.7 -- | This module provide a totally partial and incomplete maping of Exif -- values. Used for Tiff parsing and reused for Exif extraction. module Codec.Picture.Metadata.Exif -- | Tag values used for exif fields. Completly incomplete data ExifTag TagPhotometricInterpretation :: ExifTag -- | Short type TagCompression :: ExifTag -- | Short or long type TagImageWidth :: ExifTag -- | Short or long type TagImageLength :: ExifTag -- | Rational type TagXResolution :: ExifTag -- | Rational type TagYResolution :: ExifTag TagResolutionUnit :: ExifTag -- | Short or long type TagRowPerStrip :: ExifTag -- | Short or long TagStripByteCounts :: ExifTag -- | Short or long TagStripOffsets :: ExifTag TagBitsPerSample :: ExifTag -- | Short TagColorMap :: ExifTag TagTileWidth :: ExifTag TagTileLength :: ExifTag TagTileOffset :: ExifTag TagTileByteCount :: ExifTag -- | Short TagSamplesPerPixel :: ExifTag TagArtist :: ExifTag TagDocumentName :: ExifTag TagSoftware :: ExifTag -- | Short TagPlanarConfiguration :: ExifTag TagOrientation :: ExifTag -- | Short TagSampleFormat :: ExifTag TagInkSet :: ExifTag TagSubfileType :: ExifTag TagFillOrder :: ExifTag TagYCbCrCoeff :: ExifTag TagYCbCrSubsampling :: ExifTag TagYCbCrPositioning :: ExifTag TagReferenceBlackWhite :: ExifTag TagXPosition :: ExifTag TagYPosition :: ExifTag TagExtraSample :: ExifTag TagImageDescription :: ExifTag TagPredictor :: ExifTag TagCopyright :: ExifTag TagMake :: ExifTag TagModel :: ExifTag TagDateTime :: ExifTag TagGPSInfo :: ExifTag TagJpegProc :: ExifTag TagJPEGInterchangeFormat :: ExifTag TagJPEGInterchangeFormatLength :: ExifTag TagJPEGRestartInterval :: ExifTag TagJPEGLosslessPredictors :: ExifTag TagJPEGPointTransforms :: ExifTag TagJPEGQTables :: ExifTag TagJPEGDCTables :: ExifTag TagJPEGACTables :: ExifTag TagExifOffset :: ExifTag TagUnknown :: !Word16 -> ExifTag -- | Possible data held by an Exif tag data ExifData ExifNone :: ExifData ExifLong :: !Word32 -> ExifData ExifShort :: !Word16 -> ExifData ExifString :: !ByteString -> ExifData ExifUndefined :: !ByteString -> ExifData ExifShorts :: !(Vector Word16) -> ExifData ExifLongs :: !(Vector Word32) -> ExifData ExifRational :: !Word32 -> !Word32 -> ExifData ExifSignedRational :: !Int32 -> !Int32 -> ExifData ExifIFD :: ![(ExifTag, ExifData)] -> ExifData -- | Convert a value to it's corresponding Exif tag. Will often be written -- as TagUnknown tagOfWord16 :: Word16 -> ExifTag -- | Convert a tag to it's corresponding value. word16OfTag :: ExifTag -> Word16 instance GHC.Show.Show Codec.Picture.Metadata.Exif.ExifData instance GHC.Show.Show Codec.Picture.Metadata.Exif.ExifTag instance GHC.Classes.Ord Codec.Picture.Metadata.Exif.ExifTag instance GHC.Classes.Eq Codec.Picture.Metadata.Exif.ExifTag instance Control.DeepSeq.NFData Codec.Picture.Metadata.Exif.ExifTag instance Control.DeepSeq.NFData Codec.Picture.Metadata.Exif.ExifData -- | Module providing the basic types for image manipulation in the -- library. Defining the types used to store all those _Juicy Pixels_ module Codec.Picture.Types -- | The main type of this package, one that most functions work on, is -- Image. -- -- Parameterized by the underlying pixel format it forms a rigid type. If -- you wish to store images of different or unknown pixel formats use -- DynamicImage. -- -- Image is essentially a rectangular pixel buffer of specified width and -- height. The coordinates are assumed to start from the upper-left -- corner of the image, with the horizontal position first and vertical -- second. data Image a Image :: {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> Vector (PixelBaseComponent a) -> Image a -- | Width of the image in pixels [imageWidth] :: Image a -> {-# UNPACK #-} !Int -- | Height of the image in pixels. [imageHeight] :: Image a -> {-# UNPACK #-} !Int -- | Image pixel data. To extract pixels at a given position you should use -- the helper functions. -- -- Internally pixel data is stored as consecutively packed lines from top -- to bottom, scanned from left to right within individual lines, from -- first to last color component within each pixel. [imageData] :: Image a -> Vector (PixelBaseComponent a) -- | Image or pixel buffer, the coordinates are assumed to start from the -- upper-left corner of the image, with the horizontal position first, -- then the vertical one. The image can be transformed in place. data MutableImage s a MutableImage :: {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> STVector s (PixelBaseComponent a) -> MutableImage s a -- | Width of the image in pixels [mutableImageWidth] :: MutableImage s a -> {-# UNPACK #-} !Int -- | Height of the image in pixels. [mutableImageHeight] :: MutableImage s a -> {-# UNPACK #-} !Int -- | The real image, to extract pixels at some position you should use the -- helpers functions. [mutableImageData] :: MutableImage s a -> STVector s (PixelBaseComponent a) -- | Image type enumerating all predefined pixel types. It enables loading -- and use of images of different pixel types. data DynamicImage -- | A greyscale image. ImageY8 :: (Image Pixel8) -> DynamicImage -- | A greyscale image with 16bit components ImageY16 :: (Image Pixel16) -> DynamicImage -- | A greyscale HDR image ImageYF :: (Image PixelF) -> DynamicImage -- | An image in greyscale with an alpha channel. ImageYA8 :: (Image PixelYA8) -> DynamicImage -- | An image in greyscale with alpha channel on 16 bits. ImageYA16 :: (Image PixelYA16) -> DynamicImage -- | An image in true color. ImageRGB8 :: (Image PixelRGB8) -> DynamicImage -- | An image in true color with 16bit depth. ImageRGB16 :: (Image PixelRGB16) -> DynamicImage -- | An image with HDR pixels ImageRGBF :: (Image PixelRGBF) -> DynamicImage -- | An image in true color and an alpha channel. ImageRGBA8 :: (Image PixelRGBA8) -> DynamicImage -- | A true color image with alpha on 16 bits. ImageRGBA16 :: (Image PixelRGBA16) -> DynamicImage -- | An image in the colorspace used by Jpeg images. ImageYCbCr8 :: (Image PixelYCbCr8) -> DynamicImage -- | An image in the colorspace CMYK ImageCMYK8 :: (Image PixelCMYK8) -> DynamicImage -- | An image in the colorspace CMYK and 16 bits precision ImageCMYK16 :: (Image PixelCMYK16) -> DynamicImage -- | Type for the palette used in Gif & PNG files. type Palette = Image PixelRGB8 -- | Create a mutable image, filled with the given background color. createMutableImage :: (Pixel px, PrimMonad m) => Int -> Int -> px -> m (MutableImage (PrimState m) px) -- | Create a mutable image with garbage as content. All data is -- uninitialized. newMutableImage :: (Pixel px, PrimMonad m) => Int -> Int -> m (MutableImage (PrimState m) px) -- | `O(n)` Yield an immutable copy of an image by making a copy of it freezeImage :: (Storable (PixelBaseComponent px), PrimMonad m) => MutableImage (PrimState m) px -> m (Image px) -- | `O(1)` Unsafe convert a mutable image to an immutable one without -- copying. The mutable image may not be used after this operation. unsafeFreezeImage :: (Storable (PixelBaseComponent a), PrimMonad m) => MutableImage (PrimState m) a -> m (Image a) -- | `O(n)` Yield a mutable copy of an image by making a copy of it. thawImage :: (Storable (PixelBaseComponent px), PrimMonad m) => Image px -> m (MutableImage (PrimState m) px) -- | `O(1)` Unsafe convert an imutable image to an mutable one without -- copying. The source image shouldn't be used after this operation. unsafeThawImage :: (Storable (PixelBaseComponent px), PrimMonad m) => Image px -> m (MutableImage (PrimState m) px) -- | Traversal type matching the definition in the Lens package. type Traversal s t a b = forall f. Applicative f => (a -> f b) -> s -> f t -- | Traversal in "raster" order, from left to right the top to bottom. -- This traversal is matching pixelMap in spirit. -- -- Since 3.2.4 imagePixels :: (Pixel pxa, Pixel pxb) => Traversal (Image pxa) (Image pxb) pxa pxb -- | Traversal providing the pixel position with it's value. The traversal -- in raster order, from lef to right, then top to bottom. The traversal -- match pixelMapXY in spirit. -- -- Since 3.2.4 imageIPixels :: (Pixel pxa, Pixel pxb) => Traversal (Image pxa) (Image pxb) (Int, Int, pxa) pxb -- | Type alias for 8bit greyscale pixels. For simplicity, greyscale pixels -- use plain numbers instead of a separate type. type Pixel8 = Word8 -- | Type alias for 16bit greyscale pixels. type Pixel16 = Word16 -- | Type alias for 32bit greyscale pixels. type Pixel32 = Word32 -- | Type alias for 32bit floating point greyscale pixels. The standard -- bounded value range is mapped to the closed interval [0,1] i.e. -- --
-- map promotePixel [0, 1 .. 255 :: Pixel8] == [0/255, 1/255 .. 1.0 :: PixelF] --type PixelF = Float -- | Pixel type storing 8bit Luminance (Y) and alpha (A) information. -- Values are stored in the following order: -- --
-- mixWith f (PixelRGB8 ra ga ba) (PixelRGB8 rb gb bb) = -- PixelRGB8 (f 0 ra rb) (f 1 ga gb) (f 2 ba bb) --mixWith :: Pixel a => (Int -> PixelBaseComponent a -> PixelBaseComponent a -> PixelBaseComponent a) -> a -> a -> a -- | Extension of the mixWith which separate the treatment of the -- color components of the alpha value (transparency component). For -- pixel without alpha components, it is equivalent to mixWith. -- --
-- mixWithAlpha f fa (PixelRGBA8 ra ga ba aa) (PixelRGB8 rb gb bb ab) = -- PixelRGBA8 (f 0 ra rb) (f 1 ga gb) (f 2 ba bb) (fa aa ab) --mixWithAlpha :: Pixel a => (Int -> PixelBaseComponent a -> PixelBaseComponent a -> PixelBaseComponent a) -> (PixelBaseComponent a -> PixelBaseComponent a -> PixelBaseComponent a) -> a -> a -> a -- | Return the opacity of a pixel, if the pixel has an alpha layer, return -- the alpha value. If the pixel doesn't have an alpha value, return a -- value representing the opaqueness. pixelOpacity :: Pixel a => a -> PixelBaseComponent a -- | Return the number of components of the pixel componentCount :: Pixel a => a -> Int -- | Apply a function to each component of a pixel. If the color type -- possess an alpha (transparency channel), it is treated like the other -- color components. colorMap :: Pixel a => (PixelBaseComponent a -> PixelBaseComponent a) -> a -> a -- | Calculate the index for the begining of the pixel pixelBaseIndex :: Pixel a => Image a -> Int -> Int -> Int -- | Calculate theindex for the begining of the pixel at position x y mutablePixelBaseIndex :: Pixel a => MutableImage s a -> Int -> Int -> Int -- | Extract a pixel at a given position, (x, y), the origin is assumed to -- be at the corner top left, positive y to the bottom of the image pixelAt :: Pixel a => Image a -> Int -> Int -> a -- | Same as pixelAt but for mutable images. readPixel :: (Pixel a, PrimMonad m) => MutableImage (PrimState m) a -> Int -> Int -> m a -- | Write a pixel in a mutable image at position x y writePixel :: (Pixel a, PrimMonad m) => MutableImage (PrimState m) a -> Int -> Int -> a -> m () -- | Unsafe version of pixelAt, read a pixel at the given index without -- bound checking (if possible). The index is expressed in number -- (PixelBaseComponent a) unsafePixelAt :: Pixel a => Vector (PixelBaseComponent a) -> Int -> a -- | Unsafe version of readPixel, read a pixel at the given position -- without bound checking (if possible). The index is expressed in number -- (PixelBaseComponent a) unsafeReadPixel :: (Pixel a, PrimMonad m) => STVector (PrimState m) (PixelBaseComponent a) -> Int -> m a -- | Unsafe version of writePixel, write a pixel at the given position -- without bound checking. This can be _really_ unsafe. The index is -- expressed in number (PixelBaseComponent a) unsafeWritePixel :: (Pixel a, PrimMonad m) => STVector (PrimState m) (PixelBaseComponent a) -> Int -> a -> m () -- | This class abstract colorspace conversion. This conversion can be -- lossy, which ColorConvertible cannot class (Pixel a, Pixel b) => ColorSpaceConvertible a b where convertImage = pixelMap convertPixel -- | Pass a pixel from a colorspace (say RGB) to the second one (say YCbCr) convertPixel :: ColorSpaceConvertible a b => a -> b -- | Helper function to convert a whole image by taking a copy it. convertImage :: ColorSpaceConvertible a b => Image a -> Image b -- | Helper class to help extract a luma plane out of an image or a pixel class (Pixel a, Pixel (PixelBaseComponent a)) => LumaPlaneExtractable a where extractLumaPlane = pixelMap computeLuma -- | Compute the luminance part of a pixel computeLuma :: LumaPlaneExtractable a => a -> PixelBaseComponent a -- | Extract a luma plane out of an image. This method is in the typeclass -- to help performant implementation. -- --
-- jpegToGrayScale :: FilePath -> FilePath -> IO () -- jpegToGrayScale source dest --extractLumaPlane :: LumaPlaneExtractable a => Image a -> Image (PixelBaseComponent a) -- | Class modeling transparent pixel, should provide a method to combine -- transparent pixels class (Pixel a, Pixel b) => TransparentPixel a b | a -> b -- | Just return the opaque pixel value dropTransparency :: TransparentPixel a b => a -> b -- | access the transparency (alpha layer) of a given transparent pixel -- type. -- | Deprecated: please use pixelOpacity instead getTransparency :: TransparentPixel a b => a -> PixelBaseComponent a -- | map equivalent for an image, working at the pixel level. Little -- example : a brightness function for an rgb image -- --
-- brightnessRGB8 :: Int -> Image PixelRGB8 -> Image PixelRGB8 -- brightnessRGB8 add = pixelMap brightFunction -- where up v = fromIntegral (fromIntegral v + add) -- brightFunction (PixelRGB8 r g b) = -- PixelRGB8 (up r) (up g) (up b) --pixelMap :: (Pixel a, Pixel b) => (a -> b) -> Image a -> Image b -- | Just like pixelMap only the function takes the pixel -- coordinates as additional parameters. pixelMapXY :: (Pixel a, Pixel b) => (Int -> Int -> a -> b) -> Image a -> Image b -- | Fold over the pixel of an image with a raster scan order: from top to -- bottom, left to right pixelFold :: (Pixel pixel) => (acc -> Int -> Int -> pixel -> acc) -> acc -> Image pixel -> acc -- | Fold over the pixel of an image with a raster scan order: from top to -- bottom, left to right, carrying out a state pixelFoldM :: (Pixel pixel, Monad m) => (acc -> Int -> Int -> pixel -> m acc) -> acc -> Image pixel -> m acc -- | Fold over the pixel of an image with a raster scan order: from top to -- bottom, left to right. This functions is analog to the foldMap from -- the Foldable typeclass, but due to the Pixel constraint, Image -- cannot be made an instance of it. pixelFoldMap :: (Pixel px, Monoid m) => (px -> m) -> Image px -> m -- | Helper function to help extract information from dynamic image. To get -- the width of a dynamic image, you can use the following snippet: -- --
-- dynWidth :: DynamicImage -> Int -- dynWidth img = dynamicMap imageWidth img --dynamicMap :: (forall pixel. (Pixel pixel) => Image pixel -> a) -> DynamicImage -> a -- | Equivalent of the pixelMap function for the dynamic images. You -- can perform pixel colorspace independant operations with this -- function. -- -- For instance, if you want to extract a square crop of any image, -- without caring about colorspace, you can use the following snippet. -- --
-- dynSquare :: DynamicImage -> DynamicImage -- dynSquare = dynamicPixelMap squareImage -- -- squareImage :: Pixel a => Image a -> Image a -- squareImage img = generateImage (\x y -> pixelAt img x y) edge edge -- where edge = min (imageWidth img) (imageHeight img) --dynamicPixelMap :: (forall pixel. (Pixel pixel) => Image pixel -> Image pixel) -> DynamicImage -> DynamicImage -- | For any image with an alpha component (transparency), drop it, -- returning a pure opaque image. dropAlphaLayer :: (TransparentPixel a b) => Image a -> Image b -- | Create an image using a monadic initializer function. The function -- will receive values from 0 to width-1 for the x parameter and 0 to -- height-1 for the y parameter. The coordinates 0,0 are the upper left -- corner of the image, and (width-1, height-1) the lower right corner. -- -- The function is called for each pixel in the line from left to right -- (0 to width - 1) and for each line (0 to height - 1). withImage :: (Pixel pixel, PrimMonad m) => Int -> Int -> (Int -> Int -> m pixel) -> m (Image pixel) -- | Combine, pixel by pixel and component by component the values of 3 -- different images. Usage example: -- --
-- averageBrightNess c1 c2 c3 = clamp $ toInt c1 + toInt c2 + toInt c3 -- where clamp = fromIntegral . min 0 . max 255 -- toInt :: a -> Int -- toInt = fromIntegral -- ziPixelComponent3 averageBrightNess img1 img2 img3 --zipPixelComponent3 :: (Storable (PixelBaseComponent px)) => (PixelBaseComponent px -> PixelBaseComponent px -> PixelBaseComponent px -> PixelBaseComponent px) -> Image px -> Image px -> Image px -> Image px -- | Create an image given a function to generate pixels. The function will -- receive values from 0 to width-1 for the x parameter and 0 to height-1 -- for the y parameter. The coordinates 0,0 are the upper left corner of -- the image, and (width-1, height-1) the lower right corner. -- -- for example, to create a small gradient image: -- --
-- imageCreator :: String -> IO () -- imageCreator path = writePng path $ generateImage pixelRenderer 250 300 -- where pixelRenderer x y = PixelRGB8 (fromIntegral x) (fromIntegral y) 128 --generateImage :: (Pixel px) => (Int -> Int -> px) -> Int -> Int -> Image px -- | Create an image given a function to generate pixels. The function will -- receive values from 0 to width-1 for the x parameter and 0 to height-1 -- for the y parameter. The coordinates 0,0 are the upper left corner of -- the image, and (width-1, height-1) the lower right corner. -- -- the acc parameter is a user defined one. -- -- The function is called for each pixel in the line from left to right -- (0 to width - 1) and for each line (0 to height - 1). generateFoldImage :: (Pixel a) => (acc -> Int -> Int -> (acc, a)) -> acc -> Int -> Int -> (acc, Image a) -- | Perform a gamma correction for an image with HDR pixels. gammaCorrection :: PixelF -> Image PixelRGBF -> Image PixelRGBF -- | Perform a tone mapping operation on an High dynamic range image. toneMapping :: PixelF -> Image PixelRGBF -> Image PixelRGBF -- | Class used to describle plane present in the pixel type. If a pixel -- has a plane description associated, you can use the plane name to -- extract planes independently. class ColorPlane pixel planeToken -- | Define the plane for the red color component data PlaneRed PlaneRed :: PlaneRed -- | Define the plane for the green color component data PlaneGreen PlaneGreen :: PlaneGreen -- | Define the plane for the blue color component data PlaneBlue PlaneBlue :: PlaneBlue -- | Define the plane for the alpha (transparency) component data PlaneAlpha PlaneAlpha :: PlaneAlpha -- | Define the plane for the luma component data PlaneLuma PlaneLuma :: PlaneLuma -- | Define the plane for the Cr component data PlaneCr PlaneCr :: PlaneCr -- | Define the plane for the Cb component data PlaneCb PlaneCb :: PlaneCb -- | Define plane for the cyan component of the CMYK color space. data PlaneCyan PlaneCyan :: PlaneCyan -- | Define plane for the magenta component of the CMYK color space. data PlaneMagenta PlaneMagenta :: PlaneMagenta -- | Define plane for the yellow component of the CMYK color space. data PlaneYellow PlaneYellow :: PlaneYellow -- | Define plane for the black component of the CMYK color space. data PlaneBlack PlaneBlack :: PlaneBlack -- | Extract a color plane from an image given a present plane in the image -- examples: -- --
-- extractRedPlane :: Image PixelRGB8 -> Image Pixel8 -- extractRedPlane = extractComponent PlaneRed --extractComponent :: (Pixel px, Pixel (PixelBaseComponent px), PixelBaseComponent (PixelBaseComponent px) ~ PixelBaseComponent px, ColorPlane px plane) => plane -> Image px -> Image (PixelBaseComponent px) -- | Extract a plane of an image. Returns the requested color component as -- a greyscale image. -- -- If you ask for a component out of bound, the error function -- will be called. unsafeExtractComponent :: (Pixel a, Pixel (PixelBaseComponent a), PixelBaseComponent (PixelBaseComponent a) ~ PixelBaseComponent a) => Int -> Image a -> Image (PixelBaseComponent a) -- | This typeclass exist for performance reason, it allow to pack a pixel -- value to a simpler "primitive" data type to allow faster writing to -- moemory. class PackeablePixel a where type family PackedRepresentation a -- | The packing function, allowing to transform to a primitive. packPixel :: PackeablePixel a => a -> PackedRepresentation a -- | Inverse transformation, to speed up reading unpackPixel :: PackeablePixel a => PackedRepresentation a -> a -- | This function will fill an image with a simple packeable pixel. It -- will be faster than any unsafeWritePixel. fillImageWith :: (Pixel px, PackeablePixel px, PrimMonad m, Storable (PackedRepresentation px)) => MutableImage (PrimState m) px -> px -> m () -- | Read a packeable pixel from an image. Equivalent to unsafeReadPixel readPackedPixelAt :: (Pixel px, PackeablePixel px, Storable (PackedRepresentation px), PrimMonad m) => MutableImage (PrimState m) px -> Int -> m px -- | Write a packeable pixel into an image. equivalent to unsafeWritePixel. writePackedPixelAt :: (Pixel px, PackeablePixel px, Storable (PackedRepresentation px), PrimMonad m) => MutableImage (PrimState m) px -> Int -> px -> m () -- | Fill a packeable pixel between two bounds. unsafeWritePixelBetweenAt :: (PrimMonad m, Pixel px, PackeablePixel px, Storable (PackedRepresentation px)) => MutableImage (PrimState m) px -> px -> Int -> Int -> m () instance GHC.Show.Show Codec.Picture.Types.PixelRGBA16 instance GHC.Classes.Ord Codec.Picture.Types.PixelRGBA16 instance GHC.Classes.Eq Codec.Picture.Types.PixelRGBA16 instance GHC.Show.Show Codec.Picture.Types.PixelRGBA8 instance GHC.Classes.Ord Codec.Picture.Types.PixelRGBA8 instance GHC.Classes.Eq Codec.Picture.Types.PixelRGBA8 instance GHC.Show.Show Codec.Picture.Types.PixelCMYK16 instance GHC.Classes.Ord Codec.Picture.Types.PixelCMYK16 instance GHC.Classes.Eq Codec.Picture.Types.PixelCMYK16 instance GHC.Show.Show Codec.Picture.Types.PixelCMYK8 instance GHC.Classes.Ord Codec.Picture.Types.PixelCMYK8 instance GHC.Classes.Eq Codec.Picture.Types.PixelCMYK8 instance GHC.Show.Show Codec.Picture.Types.PixelYCbCr8 instance GHC.Classes.Ord Codec.Picture.Types.PixelYCbCr8 instance GHC.Classes.Eq Codec.Picture.Types.PixelYCbCr8 instance GHC.Show.Show Codec.Picture.Types.PixelRGBF instance GHC.Classes.Ord Codec.Picture.Types.PixelRGBF instance GHC.Classes.Eq Codec.Picture.Types.PixelRGBF instance GHC.Show.Show Codec.Picture.Types.PixelRGB16 instance GHC.Classes.Ord Codec.Picture.Types.PixelRGB16 instance GHC.Classes.Eq Codec.Picture.Types.PixelRGB16 instance GHC.Show.Show Codec.Picture.Types.PixelYCbCrK8 instance GHC.Classes.Ord Codec.Picture.Types.PixelYCbCrK8 instance GHC.Classes.Eq Codec.Picture.Types.PixelYCbCrK8 instance GHC.Show.Show Codec.Picture.Types.PixelRGB8 instance GHC.Classes.Ord Codec.Picture.Types.PixelRGB8 instance GHC.Classes.Eq Codec.Picture.Types.PixelRGB8 instance GHC.Show.Show Codec.Picture.Types.PixelYA16 instance GHC.Classes.Ord Codec.Picture.Types.PixelYA16 instance GHC.Classes.Eq Codec.Picture.Types.PixelYA16 instance GHC.Show.Show Codec.Picture.Types.PixelYA8 instance GHC.Classes.Ord Codec.Picture.Types.PixelYA8 instance GHC.Classes.Eq Codec.Picture.Types.PixelYA8 instance Codec.Picture.Types.TransparentPixel Codec.Picture.Types.PixelRGBA8 Codec.Picture.Types.PixelRGB8 instance Control.DeepSeq.NFData (Codec.Picture.Types.Image a) instance Control.DeepSeq.NFData (Codec.Picture.Types.MutableImage s a) instance Control.DeepSeq.NFData Codec.Picture.Types.DynamicImage instance Codec.Picture.Types.LumaPlaneExtractable Codec.Picture.Types.Pixel8 instance Codec.Picture.Types.LumaPlaneExtractable Codec.Picture.Types.Pixel16 instance Codec.Picture.Types.LumaPlaneExtractable Codec.Picture.Types.Pixel32 instance Codec.Picture.Types.LumaPlaneExtractable Codec.Picture.Types.PixelF instance Codec.Picture.Types.LumaPlaneExtractable Codec.Picture.Types.PixelRGBF instance Codec.Picture.Types.LumaPlaneExtractable Codec.Picture.Types.PixelRGBA8 instance Codec.Picture.Types.LumaPlaneExtractable Codec.Picture.Types.PixelYCbCr8 instance Codec.Picture.Types.Pixel a => Codec.Picture.Types.ColorConvertible a a instance Codec.Picture.Types.Pixel Codec.Picture.Types.Pixel8 instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.Pixel8 Codec.Picture.Types.PixelYA8 instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.Pixel8 Codec.Picture.Types.PixelF instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.Pixel8 Codec.Picture.Types.Pixel16 instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.Pixel8 Codec.Picture.Types.PixelRGB8 instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.Pixel8 Codec.Picture.Types.PixelRGBA8 instance Codec.Picture.Types.Pixel Codec.Picture.Types.Pixel16 instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.Pixel16 Codec.Picture.Types.PixelYA16 instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.Pixel16 Codec.Picture.Types.PixelRGB16 instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.Pixel16 Codec.Picture.Types.PixelRGBA16 instance Codec.Picture.Types.Pixel Codec.Picture.Types.Pixel32 instance Codec.Picture.Types.Pixel Codec.Picture.Types.PixelF instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.PixelF Codec.Picture.Types.PixelRGBF instance Codec.Picture.Types.Pixel Codec.Picture.Types.PixelYA8 instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.PixelYA8 Codec.Picture.Types.PixelRGB8 instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.PixelYA8 Codec.Picture.Types.PixelRGBA8 instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelYA8 Codec.Picture.Types.PlaneLuma instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelYA8 Codec.Picture.Types.PlaneAlpha instance Codec.Picture.Types.TransparentPixel Codec.Picture.Types.PixelYA8 Codec.Picture.Types.Pixel8 instance Codec.Picture.Types.LumaPlaneExtractable Codec.Picture.Types.PixelYA8 instance Codec.Picture.Types.Pixel Codec.Picture.Types.PixelYA16 instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.PixelYA16 Codec.Picture.Types.PixelRGBA16 instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelYA16 Codec.Picture.Types.PlaneLuma instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelYA16 Codec.Picture.Types.PlaneAlpha instance Codec.Picture.Types.TransparentPixel Codec.Picture.Types.PixelYA16 Codec.Picture.Types.Pixel16 instance Codec.Picture.Types.Pixel Codec.Picture.Types.PixelRGBF instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGBF Codec.Picture.Types.PlaneRed instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGBF Codec.Picture.Types.PlaneGreen instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGBF Codec.Picture.Types.PlaneBlue instance Codec.Picture.Types.Pixel Codec.Picture.Types.PixelRGB16 instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGB16 Codec.Picture.Types.PlaneRed instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGB16 Codec.Picture.Types.PlaneGreen instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGB16 Codec.Picture.Types.PlaneBlue instance Codec.Picture.Types.ColorSpaceConvertible Codec.Picture.Types.PixelRGB16 Codec.Picture.Types.PixelCMYK16 instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.PixelRGB16 Codec.Picture.Types.PixelRGBA16 instance Codec.Picture.Types.LumaPlaneExtractable Codec.Picture.Types.PixelRGB16 instance Codec.Picture.Types.Pixel Codec.Picture.Types.PixelRGB8 instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.PixelRGB8 Codec.Picture.Types.PixelRGBA8 instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.PixelRGB8 Codec.Picture.Types.PixelRGBF instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.PixelRGB8 Codec.Picture.Types.PixelRGB16 instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.PixelRGB8 Codec.Picture.Types.PixelRGBA16 instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGB8 Codec.Picture.Types.PlaneRed instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGB8 Codec.Picture.Types.PlaneGreen instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGB8 Codec.Picture.Types.PlaneBlue instance Codec.Picture.Types.LumaPlaneExtractable Codec.Picture.Types.PixelRGB8 instance Codec.Picture.Types.Pixel Codec.Picture.Types.PixelRGBA8 instance Codec.Picture.Types.ColorConvertible Codec.Picture.Types.PixelRGBA8 Codec.Picture.Types.PixelRGBA16 instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGBA8 Codec.Picture.Types.PlaneRed instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGBA8 Codec.Picture.Types.PlaneGreen instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGBA8 Codec.Picture.Types.PlaneBlue instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGBA8 Codec.Picture.Types.PlaneAlpha instance Codec.Picture.Types.Pixel Codec.Picture.Types.PixelRGBA16 instance Codec.Picture.Types.TransparentPixel Codec.Picture.Types.PixelRGBA16 Codec.Picture.Types.PixelRGB16 instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGBA16 Codec.Picture.Types.PlaneRed instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGBA16 Codec.Picture.Types.PlaneGreen instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGBA16 Codec.Picture.Types.PlaneBlue instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelRGBA16 Codec.Picture.Types.PlaneAlpha instance Codec.Picture.Types.Pixel Codec.Picture.Types.PixelYCbCr8 instance Codec.Picture.Types.Pixel a => Codec.Picture.Types.ColorSpaceConvertible a a instance Codec.Picture.Types.ColorSpaceConvertible Codec.Picture.Types.PixelRGB8 Codec.Picture.Types.PixelYCbCr8 instance Codec.Picture.Types.ColorSpaceConvertible Codec.Picture.Types.PixelYCbCr8 Codec.Picture.Types.PixelRGB8 instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelYCbCr8 Codec.Picture.Types.PlaneLuma instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelYCbCr8 Codec.Picture.Types.PlaneCb instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelYCbCr8 Codec.Picture.Types.PlaneCr instance Codec.Picture.Types.Pixel Codec.Picture.Types.PixelCMYK8 instance Codec.Picture.Types.ColorSpaceConvertible Codec.Picture.Types.PixelCMYK8 Codec.Picture.Types.PixelRGB8 instance Codec.Picture.Types.Pixel Codec.Picture.Types.PixelYCbCrK8 instance Codec.Picture.Types.ColorSpaceConvertible Codec.Picture.Types.PixelYCbCrK8 Codec.Picture.Types.PixelRGB8 instance Codec.Picture.Types.ColorSpaceConvertible Codec.Picture.Types.PixelYCbCrK8 Codec.Picture.Types.PixelCMYK8 instance Codec.Picture.Types.ColorSpaceConvertible Codec.Picture.Types.PixelRGB8 Codec.Picture.Types.PixelCMYK8 instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelCMYK8 Codec.Picture.Types.PlaneCyan instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelCMYK8 Codec.Picture.Types.PlaneMagenta instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelCMYK8 Codec.Picture.Types.PlaneYellow instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelCMYK8 Codec.Picture.Types.PlaneBlack instance Codec.Picture.Types.Pixel Codec.Picture.Types.PixelCMYK16 instance Codec.Picture.Types.ColorSpaceConvertible Codec.Picture.Types.PixelCMYK16 Codec.Picture.Types.PixelRGB16 instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelCMYK16 Codec.Picture.Types.PlaneCyan instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelCMYK16 Codec.Picture.Types.PlaneMagenta instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelCMYK16 Codec.Picture.Types.PlaneYellow instance Codec.Picture.Types.ColorPlane Codec.Picture.Types.PixelCMYK16 Codec.Picture.Types.PlaneBlack instance Codec.Picture.Types.PackeablePixel Codec.Picture.Types.Pixel8 instance Codec.Picture.Types.PackeablePixel Codec.Picture.Types.Pixel16 instance Codec.Picture.Types.PackeablePixel Codec.Picture.Types.Pixel32 instance Codec.Picture.Types.PackeablePixel Codec.Picture.Types.PixelF instance Codec.Picture.Types.PackeablePixel Codec.Picture.Types.PixelRGBA8 instance Codec.Picture.Types.PackeablePixel Codec.Picture.Types.PixelRGBA16 instance Codec.Picture.Types.PackeablePixel Codec.Picture.Types.PixelCMYK8 instance Codec.Picture.Types.PackeablePixel Codec.Picture.Types.PixelCMYK16 instance Codec.Picture.Types.PackeablePixel Codec.Picture.Types.PixelYA16 instance Codec.Picture.Types.PackeablePixel Codec.Picture.Types.PixelYA8 -- | This module provide some color quantisation algorithm in order to help -- in the creation of paletted images. The most important function is -- palettize which will make everything to create a nice color -- indexed image with its palette. module Codec.Picture.ColorQuant -- | Reduces an image to a color palette according to PaletteOpts -- and returns the indices image along with its Palette. palettize :: PaletteOptions -> Image PixelRGB8 -> (Image Pixel8, Palette) -- | Default palette option, which aim at the best quality and maximum -- possible colors (256) defaultPaletteOptions :: PaletteOptions -- | Define which palette creation method is used. data PaletteCreationMethod -- | MedianMeanCut method, provide the best results (visualy) at the cost -- of increased calculations. MedianMeanCut :: PaletteCreationMethod -- | Very fast algorithm (one pass), doesn't provide good looking results. Uniform :: PaletteCreationMethod -- | To specify how the palette will be created. data PaletteOptions PaletteOptions :: PaletteCreationMethod -> Bool -> Int -> PaletteOptions -- | Algorithm used to find the palette [paletteCreationMethod] :: PaletteOptions -> PaletteCreationMethod -- | Do we want to apply the dithering to the image. Enabling it often -- reduce compression ratio but enhance the perceived quality of the -- final image. [enableImageDithering] :: PaletteOptions -> Bool -- | Maximum number of color we want in the palette [paletteColorCount] :: PaletteOptions -> Int instance GHC.Base.Functor (Codec.Picture.ColorQuant.Fold a) instance GHC.Base.Applicative (Codec.Picture.ColorQuant.Fold a) instance GHC.Classes.Eq Codec.Picture.ColorQuant.Cluster instance GHC.Classes.Ord Codec.Picture.ColorQuant.Cluster -- | This module expose a common "metadata" storage for various image type. -- Different format can generate different metadatas, and write only a -- part of them. -- -- Since version 3.2.5 module Codec.Picture.Metadata -- | Dependent storage used for metadatas. All metadatas of a given kind -- are unique within this container. -- -- The current data structure is based on list, so bad performances can -- be expected. data Metadatas -- | Store various additional information about an image. If something is -- not recognized, it can be stored in an unknown tag. -- --
-- brightnessRGB8 :: Int -> Image PixelRGB8 -> Image PixelRGB8 -- brightnessRGB8 add = pixelMap brightFunction -- where up v = fromIntegral (fromIntegral v + add) -- brightFunction (PixelRGB8 r g b) = -- PixelRGB8 (up r) (up g) (up b) --pixelMap :: (Pixel a, Pixel b) => (a -> b) -> Image a -> Image b -- | Create an image given a function to generate pixels. The function will -- receive values from 0 to width-1 for the x parameter and 0 to height-1 -- for the y parameter. The coordinates 0,0 are the upper left corner of -- the image, and (width-1, height-1) the lower right corner. -- -- for example, to create a small gradient image: -- --
-- imageCreator :: String -> IO () -- imageCreator path = writePng path $ generateImage pixelRenderer 250 300 -- where pixelRenderer x y = PixelRGB8 (fromIntegral x) (fromIntegral y) 128 --generateImage :: (Pixel px) => (Int -> Int -> px) -> Int -> Int -> Image px -- | Create an image given a function to generate pixels. The function will -- receive values from 0 to width-1 for the x parameter and 0 to height-1 -- for the y parameter. The coordinates 0,0 are the upper left corner of -- the image, and (width-1, height-1) the lower right corner. -- -- the acc parameter is a user defined one. -- -- The function is called for each pixel in the line from left to right -- (0 to width - 1) and for each line (0 to height - 1). generateFoldImage :: (Pixel a) => (acc -> Int -> Int -> (acc, a)) -> acc -> Int -> Int -> (acc, Image a) -- | Create an image using a monadic initializer function. The function -- will receive values from 0 to width-1 for the x parameter and 0 to -- height-1 for the y parameter. The coordinates 0,0 are the upper left -- corner of the image, and (width-1, height-1) the lower right corner. -- -- The function is called for each pixel in the line from left to right -- (0 to width - 1) and for each line (0 to height - 1). withImage :: (Pixel pixel, PrimMonad m) => Int -> Int -> (Int -> Int -> m pixel) -> m (Image pixel) -- | Convert by any mean possible a dynamic image to an image in RGB. The -- process can lose precision while converting from 16bits pixels or -- Floating point pixels. Any alpha layer will be dropped convertRGB8 :: DynamicImage -> Image PixelRGB8 -- | Convert by any mean possible a dynamic image to an image in RGBA. The -- process can lose precision while converting from 16bits pixels or -- Floating point pixels. convertRGBA8 :: DynamicImage -> Image PixelRGBA8 -- | Traversal type matching the definition in the Lens package. type Traversal s t a b = forall f. Applicative f => (a -> f b) -> s -> f t -- | Traversal in "raster" order, from left to right the top to bottom. -- This traversal is matching pixelMap in spirit. -- -- Since 3.2.4 imagePixels :: (Pixel pxa, Pixel pxb) => Traversal (Image pxa) (Image pxb) pxa pxb -- | Traversal providing the pixel position with it's value. The traversal -- in raster order, from lef to right, then top to bottom. The traversal -- match pixelMapXY in spirit. -- -- Since 3.2.4 imageIPixels :: (Pixel pxa, Pixel pxb) => Traversal (Image pxa) (Image pxb) (Int, Int, pxa) pxb -- | Save an image to a '.bmp' file, will do everything it can to save an -- image. saveBmpImage :: FilePath -> DynamicImage -> IO () -- | Save an image to a '.jpg' file, will do everything it can to save an -- image. saveJpgImage :: Int -> FilePath -> DynamicImage -> IO () -- | Save an image to a '.gif' file, will do everything it can to save it. saveGifImage :: FilePath -> DynamicImage -> Either String (IO ()) -- | Save an image to a '.png' file, will do everything it can to save an -- image. For example, a simple transcoder to png -- --
-- transcodeToPng :: FilePath -> FilePath -> IO () -- transcodeToPng pathIn pathOut = do -- eitherImg <- readImage pathIn -- case eitherImg of -- Left _ -> return () -- Right img -> savePngImage pathOut img --savePngImage :: FilePath -> DynamicImage -> IO () -- | Save an image to a '.tiff' file, will do everything it can to save an -- image. saveTiffImage :: FilePath -> DynamicImage -> IO () -- | Save an image to a '.hdr' file, will do everything it can to save an -- image. saveRadianceImage :: FilePath -> DynamicImage -> IO () -- | All the instance of this class can be written as a bitmap file using -- this library. class BmpEncodable pixel where defaultPalette _ = BmpPalette [] -- | Write an image in a file use the bitmap format. writeBitmap :: (BmpEncodable pixel) => FilePath -> Image pixel -> IO () -- | Encode an image into a bytestring in .bmp format ready to be written -- on disk. encodeBitmap :: (BmpEncodable pixel) => Image pixel -> ByteString -- | Try to load a .bmp file. The colorspace would be RGB, RGBA or Y. readBitmap :: FilePath -> IO (Either String DynamicImage) -- | Try to decode a bitmap image. Right now this function can output the -- following pixel types : -- --
-- mixWith f (PixelRGB8 ra ga ba) (PixelRGB8 rb gb bb) = -- PixelRGB8 (f 0 ra rb) (f 1 ga gb) (f 2 ba bb) --mixWith :: Pixel a => (Int -> PixelBaseComponent a -> PixelBaseComponent a -> PixelBaseComponent a) -> a -> a -> a -- | Extension of the mixWith which separate the treatment of the -- color components of the alpha value (transparency component). For -- pixel without alpha components, it is equivalent to mixWith. -- --
-- mixWithAlpha f fa (PixelRGBA8 ra ga ba aa) (PixelRGB8 rb gb bb ab) = -- PixelRGBA8 (f 0 ra rb) (f 1 ga gb) (f 2 ba bb) (fa aa ab) --mixWithAlpha :: Pixel a => (Int -> PixelBaseComponent a -> PixelBaseComponent a -> PixelBaseComponent a) -> (PixelBaseComponent a -> PixelBaseComponent a -> PixelBaseComponent a) -> a -> a -> a -- | Return the opacity of a pixel, if the pixel has an alpha layer, return -- the alpha value. If the pixel doesn't have an alpha value, return a -- value representing the opaqueness. pixelOpacity :: Pixel a => a -> PixelBaseComponent a -- | Return the number of components of the pixel componentCount :: Pixel a => a -> Int -- | Apply a function to each component of a pixel. If the color type -- possess an alpha (transparency channel), it is treated like the other -- color components. colorMap :: Pixel a => (PixelBaseComponent a -> PixelBaseComponent a) -> a -> a -- | Calculate the index for the begining of the pixel pixelBaseIndex :: Pixel a => Image a -> Int -> Int -> Int -- | Calculate theindex for the begining of the pixel at position x y mutablePixelBaseIndex :: Pixel a => MutableImage s a -> Int -> Int -> Int -- | Extract a pixel at a given position, (x, y), the origin is assumed to -- be at the corner top left, positive y to the bottom of the image pixelAt :: Pixel a => Image a -> Int -> Int -> a -- | Same as pixelAt but for mutable images. readPixel :: (Pixel a, PrimMonad m) => MutableImage (PrimState m) a -> Int -> Int -> m a -- | Write a pixel in a mutable image at position x y writePixel :: (Pixel a, PrimMonad m) => MutableImage (PrimState m) a -> Int -> Int -> a -> m () -- | Unsafe version of pixelAt, read a pixel at the given index without -- bound checking (if possible). The index is expressed in number -- (PixelBaseComponent a) unsafePixelAt :: Pixel a => Vector (PixelBaseComponent a) -> Int -> a -- | Unsafe version of readPixel, read a pixel at the given position -- without bound checking (if possible). The index is expressed in number -- (PixelBaseComponent a) unsafeReadPixel :: (Pixel a, PrimMonad m) => STVector (PrimState m) (PixelBaseComponent a) -> Int -> m a -- | Unsafe version of writePixel, write a pixel at the given position -- without bound checking. This can be _really_ unsafe. The index is -- expressed in number (PixelBaseComponent a) unsafeWritePixel :: (Pixel a, PrimMonad m) => STVector (PrimState m) (PixelBaseComponent a) -> Int -> a -> m () -- | Type alias for 8bit greyscale pixels. For simplicity, greyscale pixels -- use plain numbers instead of a separate type. type Pixel8 = Word8 -- | Type alias for 16bit greyscale pixels. type Pixel16 = Word16 -- | Type alias for 32bit floating point greyscale pixels. The standard -- bounded value range is mapped to the closed interval [0,1] i.e. -- --
-- map promotePixel [0, 1 .. 255 :: Pixel8] == [0/255, 1/255 .. 1.0 :: PixelF] --type PixelF = Float -- | Pixel type storing 8bit Luminance (Y) and alpha (A) information. -- Values are stored in the following order: -- --