JuicyPixels 3.2.7 → 3.2.7.1
raw patch · 15 files changed
+113/−99 lines, 15 filesdep ~vectorPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: vector
API changes (from Hackage documentation)
Files
- JuicyPixels.cabal +3/−3
- changelog +4/−0
- src/Codec/Picture.hs +2/−2
- src/Codec/Picture/BitWriter.hs +3/−3
- src/Codec/Picture/Bitmap.hs +9/−9
- src/Codec/Picture/Gif.hs +9/−12
- src/Codec/Picture/Gif/LZW.hs +1/−1
- src/Codec/Picture/HDR.hs +2/−3
- src/Codec/Picture/Jpg.hs +15/−17
- src/Codec/Picture/Jpg/Common.hs +1/−1
- src/Codec/Picture/Png.hs +9/−9
- src/Codec/Picture/Png/Export.hs +9/−9
- src/Codec/Picture/Tga.hs +4/−4
- src/Codec/Picture/Tiff.hs +13/−13
- src/Codec/Picture/Types.hs +29/−13
JuicyPixels.cabal view
@@ -1,5 +1,5 @@ Name: JuicyPixels-Version: 3.2.7+Version: 3.2.7.1 Synopsis: Picture loading/serialization (in png, jpeg, bitmap, gif, tga, tiff and radiance) Description: <<data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMAAAADABAMAAACg8nE0AAAAElBMVEUAAABJqDSTWEL/qyb///8AAABH/1GTAAAAAXRSTlMAQObYZgAAAN5JREFUeF7s1sEJgFAQxFBbsAV72v5bEVYWPwT/XDxmCsi7zvHXavYREBDI3XP2GgICqBBYuwIC+/rVayPUAyAg0HvIXBcQoDFDGnUBgWQQ2Bx3AYFaRoBpAQHWb3bt2ARgGAiCYFFuwf3X5HA/McgGJWI2FdykCv4aBYzmKwDwvl6NVmUAAK2vlwEALK7fo88GANB6HQsAAAAAAAAA7P94AQCzswEAAAAAAAAAAAAAAAAAAICzh4UAO4zWAYBfRutHA4Bn5C69JhowAMGoBaMWDG0wCkbBKBgFo2AUAACPmegUST/IJAAAAABJRU5ErkJggg==>>@@ -28,7 +28,7 @@ Source-Repository this Type: git Location: git://github.com/Twinside/Juicy.Pixels.git- Tag: v3.2.7+ Tag: v3.2.7.1 Flag Mmap Description: Enable the file loading via mmap (memory map)@@ -58,7 +58,7 @@ binary >= 0.5 && < 0.9, zlib >= 0.5.3.1 && < 0.7, transformers >= 0.2,- vector >= 0.9 && < 0.12,+ vector >= 0.10 && < 0.12, primitive >= 0.4 && < 0.7, deepseq >= 1.1 && < 1.5, containers >= 0.4.2 && < 0.6
changelog view
@@ -1,6 +1,10 @@ Change log ========== +v3.2.7.1 May 2016+-----------------+ * Fix: some wrongly infinitely looping JPEG decoding+ v3.2.7 January 2016 ------------------- * Addition: convertRGB8 and convertRGBA8 helper functions
src/Codec/Picture.hs view
@@ -10,8 +10,8 @@ -- To use the library without thinking about it, look after 'decodeImage' and -- 'readImage'. -- --- Generally, the read* functions read the images from a file and try to decode --- it, and the decode* functions try to decode a bytestring. +-- Generally, the @read*@ functions read the images from a file and try to decode +-- it, and the @decode*@ functions try to decode a bytestring. -- -- For an easy image writing use the 'saveBmpImage', 'saveJpgImage' & 'savePngImage' -- functions
src/Codec/Picture/BitWriter.hs view
@@ -80,7 +80,7 @@ case B.uncons str of Nothing -> BoolState 0 0 B.empty Just (0xFF, rest) -> case B.uncons rest of- Nothing -> BoolState maxBound 0 B.empty+ Nothing -> BoolState 7 0 B.empty Just (0x00, afterMarker) -> BoolState 7 0xFF afterMarker Just (_ , afterMarker) -> initBoolStateJpg afterMarker Just (v, rest) -> BoolState 7 v rest@@ -178,9 +178,9 @@ -- code (0xFF 0x00), thus should be only used in JPEG decoding. setDecodedStringJpg :: B.ByteString -> BoolReader s () setDecodedStringJpg str = case B.uncons str of- Nothing -> S.put $ BoolState maxBound 0 B.empty+ Nothing -> S.put $ BoolState 7 0 B.empty Just (0xFF, rest) -> case B.uncons rest of- Nothing -> S.put $ BoolState maxBound 0 B.empty+ Nothing -> S.put $ BoolState 7 0 B.empty Just (0x00, afterMarker) -> -- trace "00" $ S.put $ BoolState 7 0xFF afterMarker Just (_ , afterMarker) -> setDecodedStringJpg afterMarker
src/Codec/Picture/Bitmap.hs view
@@ -349,13 +349,13 @@ dpiY = Met.dotsPerMeterToDotPerInch . fromIntegral $ yResolution hdr -- | Try to decode a bitmap image. --- Right now this function can output the following pixel types : +-- Right now this function can output the following image: -- --- * PixelRGBA8 +-- - 'ImageY8' -- --- * PixelRGB8 +-- - 'ImageRGB8' -- --- * Pixel8 +-- - 'ImageRGBA8' -- decodeBitmap :: B.ByteString -> Either String DynamicImage decodeBitmap = fmap fst . decodeBitmapWithMetadata @@ -449,19 +449,19 @@ encodeBitmapWithPaletteAndMetadata metas (defaultPalette (undefined :: pixel)) -- | Write a dynamic image in a .bmp image file if possible. --- The same restriction as encodeDynamicBitmap apply. +-- The same restriction as 'encodeDynamicBitmap' apply. writeDynamicBitmap :: FilePath -> DynamicImage -> IO (Either String Bool) writeDynamicBitmap path img = case encodeDynamicBitmap img of Left err -> return $ Left err Right b -> L.writeFile path b >> return (Right True) --- | Encode a dynamic image in bmp if possible, supported pixel type are : +-- | Encode a dynamic image in BMP if possible, supported images are: -- --- - RGB8 +-- - 'ImageY8' -- --- - RGBA8 +-- - 'ImageRGB8' -- --- - Y8 +-- - 'ImageRGBA8' -- encodeDynamicBitmap :: DynamicImage -> Either String L.ByteString encodeDynamicBitmap (ImageRGB8 img) = Right $ encodeBitmap img
src/Codec/Picture/Gif.hs view
@@ -615,8 +615,7 @@ pixelAt palette (fromIntegral $ backgroundIndex wholeDescriptor) 0 | otherwise = PixelRGB8 0 0 0 -gifAnimationApplyer :: forall px.- (Pixel px, ColorConvertible PixelRGB8 px)+gifAnimationApplyer :: forall px. (ColorConvertible PixelRGB8 px) => (Int, Int) -> Image px -> Image px -> (Image px, Maybe GraphicControlExtension, Image px) -> (Maybe GraphicControlExtension, GifImage)@@ -671,24 +670,22 @@ where hdr = gifScreenDescriptor $ gifHeader img decodeFirstGifImage _ = Left "No image in gif file" --- | Transform a raw gif image to an image, witout--- modifying the pixels.--- This function can output the following pixel types :+-- | Transform a raw gif image to an image, without modifying the pixels. This+-- function can output the following images: ----- * PixelRGB8+-- * 'ImageRGB8' ----- * PixelRGBA8+-- * 'ImageRGBA8' -- decodeGif :: B.ByteString -> Either String DynamicImage decodeGif img = decode img >>= (fmap fst . decodeFirstGifImage) --- | Transform a raw gif image to an image, witout--- modifying the pixels.--- This function can output the following pixel types :+-- | Transform a raw gif image to an image, without modifying the pixels. This+-- function can output the following images: ----- * PixelRGB8+-- * 'ImageRGB8' ----- * PixelRGBA8+-- * 'ImageRGBA8' -- -- Metadatas include Width & Height information. --
src/Codec/Picture/Gif/LZW.hs view
@@ -41,7 +41,7 @@ (..<-..) v idx = lift . (v .<-. idx) -duplicateData :: (Show a, MonadTrans t, Storable a)+duplicateData :: (MonadTrans t, Storable a) => M.STVector s a -> M.STVector s a -> Int -> Int -> Int -> t (ST s) () duplicateData src dest sourceIndex size destIndex = lift $ aux sourceIndex destIndex
src/Codec/Picture/HDR.hs view
@@ -168,10 +168,9 @@ c -> (:) <$> parsePair c <*> decodeInfos --- | Decode an HDR (radiance) image, the resulting pixel--- type can be :+-- | Decode an HDR (radiance) image, the resulting image can be: ----- * PixelRGBF+-- * 'ImageRGBF' -- decodeHDR :: B.ByteString -> Either String DynamicImage decodeHDR = fmap fst . decodeHDRWithMetadata
src/Codec/Picture/Jpg.hs view
@@ -535,33 +535,31 @@ [_,_,_,_] -> pure JpgColorSpaceCMYK _ -> Nothing --- | Try to decompress a jpeg file and decompress. The colorspace is still --- YCbCr if you want to perform computation on the luma part. You can --- convert it to RGB using 'convertImage' from the 'ColorSpaceConvertible' --- typeclass. +-- | Try to decompress and decode a jpeg file. The colorspace is still +-- YCbCr if you want to perform computation on the luma part. You can convert it +-- to RGB using 'convertImage' from the 'ColorSpaceConvertible' typeclass. -- --- This function can output the following pixel types : +-- This function can output the following images: -- --- * PixelY8 +-- * 'ImageY8' -- --- * PixelYA8 +-- * 'ImageYA8' -- --- * PixelRGB8 +-- * 'ImageRGB8' -- --- * PixelCMYK8 +-- * 'ImageCMYK8' -- --- * PixelYCbCr8 +-- * 'ImageYCbCr8' -- decodeJpeg :: B.ByteString -> Either String DynamicImage decodeJpeg = fmap fst . decodeJpegWithMetadata -- | Equivalent to 'decodeJpeg' but also extracts metadatas. -- --- Extract the following metadatas from the JFIF bloc: --- --- * DpiX +-- Extract the following metadatas from the JFIF block: -- --- * DpiY +-- * 'Codec.Picture.Metadata.DpiX' +-- * 'Codec.Picture.Metadata.DpiY' -- -- Exif metadata are also extracted if present. -- @@ -988,9 +986,9 @@ -- This function also allow to create JPEG files with the following color -- space: -- --- * Y (Pixel8) for greyscale. --- * RGB (PixelRGB8) with no color downsampling on any plane --- * CMYK (PixelCMYK8) with no color downsampling on any plane +-- * Y ('Pixel8') for greyscale. +-- * RGB ('PixelRGB8') with no color downsampling on any plane +-- * CMYK ('PixelCMYK8') with no color downsampling on any plane -- encodeDirectJpegAtQualityWithMetadata :: forall px. (JpgEncodable px) => Word8 -- ^ Quality factor
src/Codec/Picture/Jpg/Common.hs view
@@ -135,7 +135,7 @@ zigZagOrderForward = VS.generate 64 inv where inv i = fromMaybe 0 $ VS.findIndex (i ==) zigZagOrder -zigZagReorderForward :: (Storable a, Num a)+zigZagReorderForward :: (Storable a) => MutableMacroBlock s a -> MutableMacroBlock s a -> ST s (MutableMacroBlock s a)
src/Codec/Picture/Png.hs view
@@ -481,23 +481,23 @@ -- in the future. -- The resulting image let you manage the pixel types. -- --- This function can output the following pixel types: +-- This function can output the following images: -- --- * PixelY8 +-- * 'ImageY8' -- --- * PixelY16 +-- * 'ImageY16' -- --- * PixelYA8 +-- * 'ImageYA8' -- --- * PixelYA16 +-- * 'ImageYA16' -- --- * PixelRGB8 +-- * 'ImageRGB8' -- --- * PixelRGB16 +-- * 'ImageRGB16' -- --- * PixelRGBA8 +-- * 'ImageRGBA8' -- --- * PixelRGBA16 +-- * 'ImageRGBA16' -- decodePng :: B.ByteString -> Either String DynamicImage decodePng = fmap fst . decodePngWithMetadata
src/Codec/Picture/Png/Export.hs view
@@ -197,23 +197,23 @@ h = imageHeight pal isTooBig v = fromIntegral v >= w --- | Encode a dynamic image in bmp if possible, supported pixel type are : +-- | Encode a dynamic image in PNG if possible, supported images are: -- --- - Y8 +-- * 'ImageY8' -- --- - Y16 +-- * 'ImageY16' -- --- - YA8 +-- * 'ImageYA8' -- --- - YA16 +-- * 'ImageYA16' -- --- - RGB8 +-- * 'ImageRGB8' -- --- - RGB16 +-- * 'ImageRGB16' -- --- - RGBA8 +-- * 'ImageRGBA8' -- --- - RGBA16 +-- * 'ImageRGBA16' -- encodeDynamicPng :: DynamicImage -> Either String Lb.ByteString encodeDynamicPng (ImageRGB8 img) = Right $ encodePng img
src/Codec/Picture/Tga.hs view
@@ -441,13 +441,13 @@ -- | Transform a raw tga image to an image, without modifying -- the underlying pixel type. ----- This function can output the following pixel types:+-- This function can output the following images: ----- * PixelY8+-- * 'ImageY8' ----- * PixelRGB8+-- * 'ImageRGB8' ----- * PixelRGBA8+-- * 'ImageRGBA8' -- decodeTga :: B.ByteString -> Either String DynamicImage decodeTga byte = runGetStrict get byte >>= (fmap fst . unparse)
src/Codec/Picture/Tiff.hs view
@@ -757,27 +757,27 @@ -- | Decode a tiff encoded image while preserving the underlying -- pixel type (except for Y32 which is truncated to 16 bits). ----- This function can output the following pixel types:+-- This function can output the following images: ----- * PixelY8+-- * 'ImageY8' ----- * PixelY16+-- * 'ImageY16' ----- * PixelYA8+-- * 'ImageYA8' ----- * PixelYA16+-- * 'ImageYA16' ----- * PixelRGB8+-- * 'ImageRGB8' ----- * PixelRGB16+-- * 'ImageRGB16' ----- * PixelRGBA8+-- * 'ImageRGBA8' ----- * PixelRGBA16+-- * 'ImageRGBA16' ----- * PixelCMYK8+-- * 'ImageCMYK8' ----- * PixelCMYK16+-- * 'ImageCMYK16' -- decodeTiff :: B.ByteString -> Either String DynamicImage decodeTiff = fmap fst . decodeTiffWithMetadata @@ -785,8 +785,8 @@ -- | Like 'decodeTiff' but also provides some metdata present -- in the Tiff file. ----- The metadata extracted are the DpiX & DpiY information alongside--- the EXIF informations.+-- The metadata extracted are the 'Codec.Picture.Metadata.DpiX' &+-- 'Codec.Picture.Metadata.DpiY' information alongside the EXIF informations. decodeTiffWithMetadata :: B.ByteString -> Either String (DynamicImage, Metadatas) decodeTiffWithMetadata file = runGetStrict (getP file) file >>= go where
src/Codec/Picture/Types.hs view
@@ -8,8 +8,9 @@ {-# LANGUAGE Rank2Types #-} {-# LANGUAGE BangPatterns #-} {-# LANGUAGE CPP #-} --- | Module providing the basic types for image manipulation in the library. --- Defining the types used to store all those _Juicy Pixels_ +{-# LANGUAGE DeriveDataTypeable #-} +-- | Module provides basic types for image manipulation in the library. +-- Defined types are used to store all of those __Juicy Pixels__ module Codec.Picture.Types( -- * Types -- ** Image types Image( .. ) @@ -111,6 +112,7 @@ import Foreign.ForeignPtr( castForeignPtr ) import Foreign.Storable ( Storable ) import Data.Bits( unsafeShiftL, unsafeShiftR, (.|.), (.&.) ) +import Data.Typeable ( Typeable ) import Data.Word( Word8, Word16, Word32, Word64 ) import Data.Vector.Storable ( (!) ) import qualified Data.Vector.Storable as V @@ -145,6 +147,7 @@ -- component within each pixel. , imageData :: V.Vector (PixelBaseComponent a) } + deriving (Typeable) -- | Type for the palette used in Gif & PNG files. type Palette = Image PixelRGB8 @@ -159,40 +162,51 @@ -- | Define the plane for the red color component data PlaneRed = PlaneRed + deriving (Typeable) -- | Define the plane for the green color component data PlaneGreen = PlaneGreen + deriving (Typeable) -- | Define the plane for the blue color component data PlaneBlue = PlaneBlue + deriving (Typeable) -- | Define the plane for the alpha (transparency) component data PlaneAlpha = PlaneAlpha + deriving (Typeable) -- | Define the plane for the luma component data PlaneLuma = PlaneLuma + deriving (Typeable) -- | Define the plane for the Cr component data PlaneCr = PlaneCr + deriving (Typeable) -- | Define the plane for the Cb component data PlaneCb = PlaneCb + deriving (Typeable) -- | Define plane for the cyan component of the -- CMYK color space. data PlaneCyan = PlaneCyan + deriving (Typeable) -- | Define plane for the magenta component of the -- CMYK color space. data PlaneMagenta = PlaneMagenta + deriving (Typeable) -- | Define plane for the yellow component of the -- CMYK color space. data PlaneYellow = PlaneYellow + deriving (Typeable) -- | Define plane for the black component of -- the CMYK color space. data PlaneBlack = PlaneBlack + deriving (Typeable) -- | Extract a color plane from an image given a present plane in the image -- examples: @@ -294,6 +308,7 @@ -- you should use the helpers functions. , mutableImageData :: M.STVector s (PixelBaseComponent a) } + deriving (Typeable) -- | `O(n)` Yield an immutable copy of an image by making a copy of it freezeImage :: (Storable (PixelBaseComponent px), PrimMonad m) @@ -372,6 +387,7 @@ | ImageCMYK8 (Image PixelCMYK8) -- | An image in the colorspace CMYK and 16 bits precision | ImageCMYK16 (Image PixelCMYK16) + deriving (Typeable) -- | Helper function to help extract information from dynamic -- image. To get the width of a dynamic image, you can use @@ -468,7 +484,7 @@ -- data PixelYA8 = PixelYA8 {-# UNPACK #-} !Pixel8 -- Luminance {-# UNPACK #-} !Pixel8 -- Alpha value - deriving (Eq, Ord, Show) + deriving (Eq, Ord, Show, Typeable) -- | Pixel type storing 16bit Luminance (Y) and alpha (A) information. -- Values are stored in the following order: @@ -479,7 +495,7 @@ -- data PixelYA16 = PixelYA16 {-# UNPACK #-} !Pixel16 -- Luminance {-# UNPACK #-} !Pixel16 -- Alpha value - deriving (Eq, Ord, Show) + deriving (Eq, Ord, Show, Typeable) -- | Classic pixel type storing 8bit red, green and blue (RGB) information. -- Values are stored in the following order: @@ -493,7 +509,7 @@ data PixelRGB8 = PixelRGB8 {-# UNPACK #-} !Pixel8 -- Red {-# UNPACK #-} !Pixel8 -- Green {-# UNPACK #-} !Pixel8 -- Blue - deriving (Eq, Ord, Show) + deriving (Eq, Ord, Show, Typeable) -- | Pixel type storing value for the YCCK color space: -- @@ -509,7 +525,7 @@ {-# UNPACK #-} !Pixel8 {-# UNPACK #-} !Pixel8 {-# UNPACK #-} !Pixel8 - deriving (Eq, Ord, Show) + deriving (Eq, Ord, Show, Typeable) -- | Pixel type storing 16bit red, green and blue (RGB) information. -- Values are stored in the following order: @@ -523,7 +539,7 @@ data PixelRGB16 = PixelRGB16 {-# UNPACK #-} !Pixel16 -- Red {-# UNPACK #-} !Pixel16 -- Green {-# UNPACK #-} !Pixel16 -- Blue - deriving (Eq, Ord, Show) + deriving (Eq, Ord, Show, Typeable) -- | HDR pixel type storing floating point 32bit red, green and blue (RGB) information. -- Same value range and comments apply as for 'PixelF'. @@ -538,7 +554,7 @@ data PixelRGBF = PixelRGBF {-# UNPACK #-} !PixelF -- Red {-# UNPACK #-} !PixelF -- Green {-# UNPACK #-} !PixelF -- Blue - deriving (Eq, Ord, Show) + deriving (Eq, Ord, Show, Typeable) -- | Pixel type storing 8bit luminance, blue difference and red difference (YCbCr) information. -- Values are stored in the following order: @@ -552,7 +568,7 @@ data PixelYCbCr8 = PixelYCbCr8 {-# UNPACK #-} !Pixel8 -- Y luminance {-# UNPACK #-} !Pixel8 -- Cb blue difference {-# UNPACK #-} !Pixel8 -- Cr red difference - deriving (Eq, Ord, Show) + deriving (Eq, Ord, Show, Typeable) -- | Pixel type storing 8bit cyan, magenta, yellow and black (CMYK) information. -- Values are stored in the following order: @@ -569,7 +585,7 @@ {-# UNPACK #-} !Pixel8 -- Magenta {-# UNPACK #-} !Pixel8 -- Yellow {-# UNPACK #-} !Pixel8 -- Black - deriving (Eq, Ord, Show) + deriving (Eq, Ord, Show, Typeable) -- | Pixel type storing 16bit cyan, magenta, yellow and black (CMYK) information. -- Values are stored in the following order: @@ -586,7 +602,7 @@ {-# UNPACK #-} !Pixel16 -- Magenta {-# UNPACK #-} !Pixel16 -- Yellow {-# UNPACK #-} !Pixel16 -- Black - deriving (Eq, Ord, Show) + deriving (Eq, Ord, Show, Typeable) -- | Classical pixel type storing 8bit red, green, blue and alpha (RGBA) information. @@ -604,7 +620,7 @@ {-# UNPACK #-} !Pixel8 -- Green {-# UNPACK #-} !Pixel8 -- Blue {-# UNPACK #-} !Pixel8 -- Alpha - deriving (Eq, Ord, Show) + deriving (Eq, Ord, Show, Typeable) -- | Pixel type storing 16bit red, green, blue and alpha (RGBA) information. -- Values are stored in the following order: @@ -621,7 +637,7 @@ {-# UNPACK #-} !Pixel16 -- Green {-# UNPACK #-} !Pixel16 -- Blue {-# UNPACK #-} !Pixel16 -- Alpha - deriving (Eq, Ord, Show) + deriving (Eq, Ord, Show, Typeable) -- | Definition of pixels used in images. Each pixel has a color space, and a representative -- component (Word8 or Float).