packages feed

jammittools 0.5.0.2 → 0.5.0.3

raw patch · 2 files changed

+32/−36 lines, 2 filesdep ~HPDFdep ~JuicyPixelsdep ~jammittoolsPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: HPDF, JuicyPixels, jammittools, process, resourcet, transformers, vector

API changes (from Hackage documentation)

Files

jammittools.cabal view
@@ -1,5 +1,5 @@ Name:               jammittools-Version:            0.5.0.2+Version:            0.5.0.3 Synopsis:           Export sheet music and audio from Windows/Mac app Jammit Description: @@ -33,23 +33,22 @@     Sound.Jammit.Internal.PropertyList   hs-source-dirs:   src   build-depends:-    base            >= 4.6.0.1 && < 5-    , xml           >= 1.3.14  && < 1.4-    , text          >= 1.2.1.1 && < 1.3-    , directory     >= 1.2.0.1 && < 1.3-    , filepath      >= 1.3.0.1 && < 1.5-    , containers    >= 0.5.0.0 && < 0.6-    , process       >= 1.1.0.2 && < 1.3-    , temporary     >= 1.1.2.5 && < 1.3-    , transformers  >= 0.3.0.0 && < 0.5-    , JuicyPixels   >= 3.2.2   && < 3.3-    , HPDF          >= 1.4.7   && < 1.5-    , bytestring   >= 0.10.4.0 && < 0.11-    , conduit       >= 1.2.3.1 && < 1.3-    , vector      >= 0.10.12.2 && < 0.11-    -    , conduit-audio >= 0.1 && < 0.3-    , resourcet+    base            >= 4.6.0.1   && < 5+    , xml           >= 1.3.14    && < 1.4+    , text          >= 1.2.1.1   && < 1.3+    , directory     >= 1.2.0.1   && < 1.3+    , filepath      >= 1.3.0.1   && < 1.5+    , containers    >= 0.5.0.0   && < 0.6+    , process       >= 1.1.0.2   && < 1.5+    , temporary     >= 1.1.2.5   && < 1.3+    , transformers  >= 0.3.0.0   && < 0.6+    , JuicyPixels   >= 3.2.7     && < 3.3+    , HPDF          >= 1.4.9     && < 1.5+    , bytestring    >= 0.10.4.0  && < 0.11+    , conduit       >= 1.2.3.1   && < 1.3+    , vector        >= 0.10.12.2 && < 0.12+    , conduit-audio >= 0.1       && < 0.3+    , resourcet     >= 1.1.7.2   && < 1.2   ghc-options:      -Wall -O2   c-sources:        cbits/ima4.c @@ -62,7 +61,7 @@     , directory     >= 1.2.0.1 && < 1.3     , filepath      >= 1.3.0.1 && < 1.5     , boxes         >= 0.1.3   && < 0.2-    , jammittools   == 0.5.0.2+    , jammittools   == 0.5.0.3   ghc-options:      -Wall -O2  source-repository head
src/Sound/Jammit/Internal/Image.hs view
@@ -4,7 +4,7 @@ ) where  import qualified Codec.Picture as P-import Codec.Picture.Types (convertImage, dropTransparency)+import Codec.Picture.Types (convertImage) import Control.Monad (forM_, replicateM) import Control.Monad.IO.Class (MonadIO) import Control.Monad.Trans.Class (lift)@@ -16,20 +16,18 @@  import Sound.Jammit.Internal.TempIO -loadPNG :: FilePath -> IO (P.Image P.PixelRGBA8)+loadPNG :: FilePath -> IO (P.Image P.PixelRGB8) loadPNG fp = do   Right dyn <- P.readImage fp-  case dyn of-    P.ImageRGBA8 i -> return i-    _              -> error "loadPNG: pixels aren't RGBA8"+  return $ P.convertRGB8 dyn  pngChunks :: (MonadIO m) =>-  Int -> [FilePath] -> C.Source m (P.Image P.PixelRGBA8)+  Int -> [FilePath] -> C.Source m (P.Image P.PixelRGB8) pngChunks h fps = let-  raw :: (MonadIO m) => C.Source m (P.Image P.PixelRGBA8)+  raw :: (MonadIO m) => C.Source m (P.Image P.PixelRGB8)   raw = mapM_ (\fp -> liftIO (loadPNG fp) >>= C.yield) fps   chunk :: (Monad m) =>-    C.Conduit (P.Image P.PixelRGBA8) m (P.Image P.PixelRGBA8)+    C.Conduit (P.Image P.PixelRGB8) m (P.Image P.PixelRGB8)   chunk = C.await >>= \x -> case x of     Nothing   -> return ()     Just page -> case span (\c -> P.imageHeight c == h) $ vertSplit h page of@@ -40,12 +38,12 @@   in raw C.=$= chunk  chunksToPages :: (Monad m) =>-  Int -> C.Conduit [P.Image P.PixelRGBA8] m (P.Image P.PixelRGBA8)+  Int -> C.Conduit [P.Image P.PixelRGB8] m (P.Image P.PixelRGB8) chunksToPages n = fmap catMaybes (replicateM n C.await) >>= \systems -> case systems of   [] -> return ()   _  -> C.yield (vertConcat $ concat systems) >> chunksToPages n -sinkJPEG :: C.Sink (P.Image P.PixelRGBA8) TempIO [FilePath]+sinkJPEG :: C.Sink (P.Image P.PixelRGB8) TempIO [FilePath] sinkJPEG = go [] where   go jpegs = C.await >>= \x -> case x of     Nothing -> return jpegs@@ -62,11 +60,10 @@   sources = map (\(imgs, h) -> pngChunks (fromIntegral h) imgs) parts   in C.sequenceSources sources C.$$ chunksToPages n C.=$= sinkJPEG -saveJPEG :: FilePath -> P.Image P.PixelRGBA8 -> IO ()-saveJPEG fp img = BL.writeFile fp $ P.encodeJpegAtQuality 100 $-  convertImage $ P.pixelMap dropTransparency img+saveJPEG :: FilePath -> P.Image P.PixelRGB8 -> IO ()+saveJPEG fp img = BL.writeFile fp $ P.encodeJpegAtQuality 100 $ convertImage img -vertConcat :: [P.Image P.PixelRGBA8] -> P.Image P.PixelRGBA8+vertConcat :: [P.Image P.PixelRGB8] -> P.Image P.PixelRGB8 vertConcat [] = P.Image 0 0 V.empty -- efficient version: all images have same width, just concat vectors vertConcat allimgs@(img : imgs)@@ -81,7 +78,7 @@   w = foldr max 0 $ map P.imageWidth imgs   h = sum $ map P.imageHeight imgs   f = go imgs-  empty = P.PixelRGBA8 0 0 0 0+  empty = P.PixelRGB8 0 0 0   go [] _ _ = empty   go (i : is) x y = if y < P.imageHeight i     then if x < P.imageWidth i@@ -89,7 +86,7 @@       else empty     else go is x $ y - P.imageHeight i -vertSplit :: Int -> P.Image P.PixelRGBA8 -> [P.Image P.PixelRGBA8]+vertSplit :: Int -> P.Image P.PixelRGB8 -> [P.Image P.PixelRGB8] vertSplit h img = if P.imageHeight img <= h   then [img]   else let@@ -109,7 +106,7 @@ imagePage :: PDF.JpegFile -> PDF.PDF () imagePage jpeg = do   let (w, h) = PDF.jpegBounds jpeg-  page <- PDF.addPage $ Just $ PDF.PDFRect 0 0 (round w) (round h)+  page <- PDF.addPage $ Just $ PDF.PDFRect 0 0 w h   ref <- PDF.createPDFJpeg jpeg   PDF.drawWithPage page $ PDF.drawXObject ref