hsexif 0.1.0.0 → 0.1.0.1
raw patch · 2 files changed
+24/−20 lines, 2 filesdep ~basePVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base
API changes (from Hackage documentation)
Files
- Graphics/HsExif.hs +18/−17
- hsexif.cabal +6/−3
Graphics/HsExif.hs view
@@ -3,7 +3,7 @@ import Data.Binary.Get import qualified Data.ByteString.Lazy as B-import Control.Monad (liftM, unless, when)+import Control.Monad (liftM, unless) import qualified Data.ByteString.Char8 as Char8 import Data.Word import Data.Int@@ -23,8 +23,8 @@ -- | Read EXIF data from a lazy bytestring. parseExif :: B.ByteString -> Either String (Map ExifTag String) parseExif contents = case runGetOrFail getExif contents of- Left (bs,offset,errorMsg) -> Left errorMsg- Right (bs,offset,result) -> Right result+ Left (_,_,errorMsg) -> Left errorMsg+ Right (_,_,result) -> Right result getExif :: Get (Map ExifTag String) getExif = do@@ -38,7 +38,7 @@ markerNumber <- getWord16be dataSize <- liftM (fromIntegral . toInteger) getWord16be case markerNumber of- 0xffe1 -> parseExifBlock dataSize+ 0xffe1 -> parseExifBlock -- ffda is Start Of Stream => image -- I expect no more EXIF data after this point. 0xffda -> fail "No EXIF in JPEG" @@ -54,15 +54,15 @@ getWord32 Intel = getWord32le getWord32 Motorola = getWord32be -parseExifBlock :: Int -> Get (Map ExifTag String)-parseExifBlock blockLength = do+parseExifBlock :: Get (Map ExifTag String)+parseExifBlock = do header <- getByteString 4- null <- liftM toInteger getWord16be- unless (header == Char8.pack "Exif" && null == 0)+ nul <- liftM toInteger getWord16be+ unless (header == Char8.pack "Exif" && nul == 0) $ fail "invalid EXIF header" tiffHeaderStart <- liftM fromIntegral bytesRead byteAlign <- parseTiffHeader- exifSubIfdOffset <- liftM (fromIntegral . toInteger) (parseIfd byteAlign tiffHeaderStart)+ exifSubIfdOffset <- liftM (fromIntegral . toInteger) (parseIfd byteAlign) -- skip to the exif offset bytesReadNow <- liftM fromIntegral bytesRead skip $ (exifSubIfdOffset + tiffHeaderStart) - bytesReadNow@@ -74,6 +74,7 @@ let byteAlign = case Char8.unpack byteAlignV of "II" -> Intel "MM" -> Motorola+ _ -> error "Unknown byte alignment" alignControl <- liftM toInteger (getWord16 byteAlign) unless (alignControl == 0x2a) $ fail "exif byte alignment mismatch"@@ -81,10 +82,10 @@ skip $ ifdOffset - 8 return byteAlign -parseIfd :: ByteAlign -> Int -> Get Word32-parseIfd byteAlign tiffHeaderStart = do+parseIfd :: ByteAlign -> Get Word32+parseIfd byteAlign = do dirEntriesCount <- liftM toInteger (getWord16 byteAlign)- ifdEntries <- mapM (\_ -> parseIfEntry byteAlign tiffHeaderStart) [1..dirEntriesCount]+ ifdEntries <- mapM (\_ -> parseIfEntry byteAlign) [1..dirEntriesCount] let exifOffsetEntry = fromMaybe (error "Can't find the exif offset in the IFD") (find (\ e -> entryTag e == 0x8769) ifdEntries) let exifOffset = entryContents exifOffsetEntry@@ -93,7 +94,7 @@ parseExifSubIfd :: ByteAlign -> Int -> Get (Map ExifTag String) parseExifSubIfd byteAlign tiffHeaderStart = do dirEntriesCount <- liftM toInteger (getWord16 byteAlign)- ifdEntries <- mapM (\_ -> parseIfEntry byteAlign tiffHeaderStart) [1..dirEntriesCount]+ ifdEntries <- mapM (\_ -> parseIfEntry byteAlign) [1..dirEntriesCount] list <- mapM (decodeEntry byteAlign tiffHeaderStart) ifdEntries return $ Map.fromList list @@ -105,8 +106,8 @@ entryContents :: !Word32 } deriving Show -parseIfEntry :: ByteAlign -> Int -> Get IfEntry-parseIfEntry byteAlign tiffHeaderStart = do+parseIfEntry :: ByteAlign -> Get IfEntry+parseIfEntry byteAlign = do tagNumber <- getWord16 byteAlign dataFormat <- getWord16 byteAlign numComponents <- getWord32 byteAlign@@ -156,7 +157,7 @@ deriving (Eq, Ord, Show) getExifTag :: Word16 -> ExifTag-getExifTag entryTag = case entryTag of+getExifTag entryTagV = case entryTagV of 0x829a -> ExposureTime 0x829d -> FNumber 0x8822 -> ExposureProgram@@ -190,7 +191,7 @@ 0xa217 -> SensingMethod 0xa300 -> FileSource 0xa301 -> SceneType- _ -> Unknown entryTag+ _ -> Unknown entryTagV decodeEntry :: ByteAlign -> Int -> IfEntry -> Get (ExifTag, String) decodeEntry byteAlign tiffHeaderStart entry = do
hsexif.cabal view
@@ -2,9 +2,10 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: hsexif-version: 0.1.0.0+version: 0.1.0.1 synopsis: EXIF handling library in pure Haskell--- description: +description: The hsexif library provides functions for working with EXIF data+ contained in JPEG files. Currently it only supports reading the data. homepage: https://github.com/emmanueltouzery/hsexif license: BSD3 license-file: LICENSE@@ -20,13 +21,14 @@ exposed-modules: Graphics.HsExif -- other-modules: -- other-extensions: - build-depends: base >=4.6 && <4.7,+ build-depends: base >=4.6 && <5, binary >=0.7 && <0.8, bytestring >=0.10 && <0.11, containers >= 0.5 && <0.6, time >= 1.4 && <1.5 -- hs-source-dirs: default-language: Haskell2010+ Ghc-Options: -Wall test-suite tests type: exitcode-stdio-1.0@@ -40,3 +42,4 @@ bytestring >=0.10 && <0.11, containers >= 0.5 && <0.6, time >= 1.4 && <1.5+ Ghc-Options: -Wall