JuicyPixels 3.3.5 → 3.3.6
raw patch · 6 files changed
+42/−13 lines, 6 filesdep ~bytestringPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: bytestring
API changes (from Hackage documentation)
Files
- JuicyPixels.cabal +3/−3
- changelog +9/−0
- src/Codec/Picture/Bitmap.hs +4/−0
- src/Codec/Picture/Jpg.hs +2/−2
- src/Codec/Picture/Tiff/Internal/Types.hs +15/−6
- src/Codec/Picture/VectorByteConversion.hs +9/−2
JuicyPixels.cabal view
@@ -1,5 +1,5 @@ Name: JuicyPixels -Version: 3.3.5 +Version: 3.3.6 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.3.5 + Tag: v3.3.6 Flag Mmap Description: Enable the file loading via mmap (memory map) @@ -67,7 +67,7 @@ Ghc-options: -O3 -Wall Build-depends: base >= 4.8 && < 6, - bytestring >= 0.9 && < 0.11, + bytestring >= 0.9 && < 0.12, mtl >= 1.1 && < 2.3, binary >= 0.8.1 && < 0.9, zlib >= 0.5.3.1 && < 0.7,
changelog view
@@ -1,6 +1,15 @@ Change log ========== +v3.3.6 October 2021 +------------------- + + * Bytestring bound bump + * Fix bug #187. (Some JPEGs are misidentified as SourceTiff.) + * Fix EXIF handling of strings of four characters or fewer. + * Fix endianness bug in short ExifString and ExifUndefined. + + v3.3.5 January 2020 -------------------
src/Codec/Picture/Bitmap.hs view
@@ -517,7 +517,11 @@ -- | Helper method to cast a 'B.ByteString' to a 'VS.Vector' of some type. castByteString :: VS.Storable a => B.ByteString -> VS.Vector a +#if MIN_VERSION_bytestring(0,11,0) +castByteString (BI.BS fp len) = VS.unsafeCast $ VS.unsafeFromForeignPtr fp 0 len +#else castByteString (BI.PS fp offset len) = VS.unsafeCast $ VS.unsafeFromForeignPtr fp offset len +#endif decodeImageRGBA8 :: RGBABmpFormat -> BmpV5Header -> B.ByteString -> Image PixelRGBA8 decodeImageRGBA8 pixelFormat (BmpV5Header { width = w, height = h, bitPerPixel = bpp }) str = Image wi hi stArray where
src/Codec/Picture/Jpg.hs view
@@ -574,7 +574,7 @@ let (st, arr) = decodeBaseline jfifMeta = foldMap extractMetadatas $ app0JFifMarker st exifMeta = foldMap extractTiffMetadata $ app1ExifMarker st - meta = sizeMeta <> jfifMeta <> exifMeta + meta = jfifMeta <> exifMeta <> sizeMeta in (, meta) <$> dynamicOfColorSpace (colorSpaceOfState st) imgWidth imgHeight arr @@ -582,7 +582,7 @@ let (st, arr) = decodeProgressive jfifMeta = foldMap extractMetadatas $ app0JFifMarker st exifMeta = foldMap extractTiffMetadata $ app1ExifMarker st - meta = sizeMeta <> jfifMeta <> exifMeta + meta = jfifMeta <> exifMeta <> sizeMeta in (, meta) <$> dynamicOfColorSpace (colorSpaceOfState st) imgWidth imgHeight arr
src/Codec/Picture/Tiff/Internal/Types.hs view
@@ -240,6 +240,16 @@ getVec count = V.replicateM (fromIntegral count) + immediateBytes ofs = + let bytes = [fromIntegral $ (ofs .&. 0xFF000000) `unsafeShiftR` (3 * 8) + ,fromIntegral $ (ofs .&. 0x00FF0000) `unsafeShiftR` (2 * 8) + ,fromIntegral $ (ofs .&. 0x0000FF00) `unsafeShiftR` (1 * 8) + ,fromIntegral $ ofs .&. 0x000000FF + ] + in case endianness of + EndianLittle -> reverse bytes + EndianBig -> bytes + fetcher ImageFileDirectory { ifdIdentifier = TagExifOffset , ifdType = TypeLong , ifdCount = 1 } = do @@ -262,13 +272,12 @@ align ifd $ ExifUndefined <$> getByteString (fromIntegral count) fetcher ImageFileDirectory { ifdType = TypeUndefined, ifdOffset = ofs } = pure . ExifUndefined . B.pack $ take (fromIntegral $ ifdCount ifd) - [fromIntegral $ ofs .&. 0xFF000000 `unsafeShiftR` (3 * 8) - ,fromIntegral $ ofs .&. 0x00FF0000 `unsafeShiftR` (2 * 8) - ,fromIntegral $ ofs .&. 0x0000FF00 `unsafeShiftR` (1 * 8) - ,fromIntegral $ ofs .&. 0x000000FF - ] - fetcher ImageFileDirectory { ifdType = TypeAscii, ifdCount = count } | count > 1 = + (immediateBytes ofs) + fetcher ImageFileDirectory { ifdType = TypeAscii, ifdCount = count } | count > 4 = align ifd $ ExifString <$> getByteString (fromIntegral count) + fetcher ImageFileDirectory { ifdType = TypeAscii, ifdOffset = ofs } = + pure . ExifString . B.pack $ take (fromIntegral $ ifdCount ifd) + (immediateBytes ofs) fetcher ImageFileDirectory { ifdType = TypeShort, ifdCount = 2, ifdOffset = ofs } = pure . ExifShorts $ V.fromListN 2 valList where high = fromIntegral $ ofs `unsafeShiftR` 16
src/Codec/Picture/VectorByteConversion.hs view
@@ -21,12 +21,19 @@ import Codec.Picture.Types +mkBS :: ForeignPtr Word8 -> Int -> Int -> S.ByteString +#if MIN_VERSION_bytestring(0,11,0) +mkBS fptr off = S.BS (fptr `S.plusForeignPtr` off) +#else +mkBS = S.PS +#endif + blitVector :: Vector Word8 -> Int -> Int -> B.ByteString -blitVector vec atIndex = S.PS ptr (offset + atIndex) +blitVector vec atIndex = mkBS ptr (offset + atIndex) where (ptr, offset, _length) = unsafeToForeignPtr vec toByteString :: forall a. (Storable a) => Vector a -> B.ByteString -toByteString vec = S.PS (castForeignPtr ptr) offset (len * size) +toByteString vec = mkBS (castForeignPtr ptr) offset (len * size) where (ptr, offset, len) = unsafeToForeignPtr vec size = sizeOf (undefined :: a)