imagemagick 0.0.2 → 0.0.3
raw patch · 13 files changed
+57/−24 lines, 13 filesdep +MonadCatchIO-transformers
Dependencies added: MonadCatchIO-transformers
Files
- Graphics/ImageMagick/MagickCore/Exception.hs +0/−2
- Graphics/ImageMagick/MagickCore/FFI/MagickCore.hsc +0/−6
- Graphics/ImageMagick/MagickCore/Gem.hs +7/−1
- Graphics/ImageMagick/MagickCore/Types/FFI/Distort.hsc +1/−0
- Graphics/ImageMagick/MagickCore/Types/FFI/Geometry.hsc +2/−0
- Graphics/ImageMagick/MagickCore/Types/FFI/PixelPacket.hsc +8/−3
- Graphics/ImageMagick/MagickCore/Types/FFI/Types.hsc +0/−2
- Graphics/ImageMagick/MagickWand/DrawingWand.hs +2/−1
- Graphics/ImageMagick/MagickWand/FFI/Types.hsc +6/−1
- Graphics/ImageMagick/MagickWand/MagickWand.hs +2/−0
- Graphics/ImageMagick/MagickWand/PixelWand.hs +7/−1
- Graphics/ImageMagick/MagickWand/WandImage.hs +15/−5
- imagemagick.cabal +7/−2
Graphics/ImageMagick/MagickCore/Exception.hs view
@@ -9,8 +9,6 @@ import Control.Exception.Base import Data.Typeable-import Foreign-import Foreign.C.String import Graphics.ImageMagick.MagickCore.Types data MagickWandException = MagickWandException ExceptionSeverity ExceptionType String
− Graphics/ImageMagick/MagickCore/FFI/MagickCore.hsc
@@ -1,6 +0,0 @@-module Graphics.ImageMagick.MagickCore.FFI.MagickCore- where--import Graphics.ImageMagick.MagickCore.Types--
Graphics/ImageMagick/MagickCore/Gem.hs view
@@ -7,7 +7,8 @@ , convertRGBToHWB ) where -import Foreign.Storable (peek)+import Foreign.Ptr (Ptr)+import Foreign.Storable (Storable, peek) import Foreign.Marshal.Alloc (alloca) import Control.Monad.IO.Class import Control.Monad.Trans.Resource@@ -15,6 +16,9 @@ import qualified Graphics.ImageMagick.MagickCore.FFI.Gem as F +with3 :: (Storable a, Storable b, Storable c) =>+ (Ptr a -> Ptr b -> Ptr c -> IO ())+ -> IO (a, b, c) with3 f = alloca (\x -> alloca (\y -> alloca (\z -> do f x y z x' <- peek x@@ -22,6 +26,8 @@ z' <- peek z return (x',y',z') )))++map3 :: (a -> b) -> (a, a, a) -> (b, b, b) map3 f (a,b,c) = (f a, f b, f c)
Graphics/ImageMagick/MagickCore/Types/FFI/Distort.hsc view
@@ -30,6 +30,7 @@ , sentinelDistortion = SentinelDistortion } +bilinearDistortion :: DistortImageMethod bilinearDistortion = bilinearForwardDistortion newtype SparseColorMethod = SparseColorMethod { unSparseColorMethod :: CInt }
Graphics/ImageMagick/MagickCore/Types/FFI/Geometry.hsc view
@@ -25,4 +25,6 @@ , staticGravity = StaticGravity } +undefinedGravity :: GravityType undefinedGravity = forgetGravity+
Graphics/ImageMagick/MagickCore/Types/FFI/PixelPacket.hsc view
@@ -4,10 +4,7 @@ module Graphics.ImageMagick.MagickCore.Types.FFI.PixelPacket where -import Data.Int-import Data.Word import Foreign-import Foreign.C.Types #include <magick/MagickCore.h> data PixelPacket @@ -16,10 +13,18 @@ sizeOf = const #size PixelPacket alignment _ = 1 +pixelPacketGetRed, pixelPacketGetGreen, pixelPacketGetBlue+ , pixelPacketGetOpacity + :: Storable a => Ptr b -> IO a pixelPacketGetRed = #peek PixelPacket, red pixelPacketGetGreen = #peek PixelPacket, green pixelPacketGetBlue = #peek PixelPacket, blue pixelPacketGetOpacity = #peek PixelPacket, opacity++pixelPacketSetRed, pixelPacketSetGreen, pixelPacketSetBlue+ , pixelPacketSetOpacity+ :: Storable a => Ptr b -> a -> IO ()+ pixelPacketSetRed = #poke PixelPacket, red pixelPacketSetGreen = #poke PixelPacket, green pixelPacketSetBlue = #poke PixelPacket, blue
Graphics/ImageMagick/MagickCore/Types/FFI/Types.hsc view
@@ -6,8 +6,6 @@ import Data.Int import Data.Word-import Foreign.C.String-import Foreign.C.Types #include <magick/MagickCore.h> type MagickRealType = #type MagickRealType
Graphics/ImageMagick/MagickWand/DrawingWand.hs view
@@ -161,12 +161,13 @@ -- , pushDrawingWand] ) where +import Control.Monad (void) import Control.Monad.IO.Class import Control.Monad.Trans.Resource import Data.ByteString (ByteString, useAsCString) import Data.Text (Text) import Data.Text.Encoding (encodeUtf8)-import Foreign hiding (rotate)+import Foreign hiding (rotate, void) import Foreign.C.Types () import Graphics.ImageMagick.MagickCore.Types import qualified Graphics.ImageMagick.MagickWand.FFI.DrawingWand as F
Graphics/ImageMagick/MagickWand/FFI/Types.hsc view
@@ -9,7 +9,6 @@ import Foreign import Foreign.C.Types-import Graphics.ImageMagick.MagickCore.Types.FFI.Types data PixelIterator data MagickWand@@ -77,11 +76,17 @@ sizeOf = const #size MagickPixelPacket alignment _ = 1 +getPixelRed, getPixelGreen, getPixelBlue, getPixelIndex+ :: Storable a => Ptr b -> IO a getPixelRed = #peek MagickPixelPacket, red getPixelGreen = #peek MagickPixelPacket, green getPixelBlue = #peek MagickPixelPacket, blue getPixelIndex = #peek MagickPixelPacket, index++setPixelRed, setPixelGreen, setPixelBlue, setPixelIndex+ :: Storable a => Ptr b -> a -> IO ()+ setPixelRed = #poke MagickPixelPacket, red setPixelGreen = #poke MagickPixelPacket, green setPixelBlue = #poke MagickPixelPacket, blue
Graphics/ImageMagick/MagickWand/MagickWand.hs view
@@ -124,12 +124,14 @@ -- end of the work, should wrap all MagickWand functions -- withMagickWandGenesis :: IO a -> IO a -- withMagickWandGenesis :: (MonadCatchIO m, MonadBaseControl IO m, MonadCatchIO (ResourceT IO)) => (ResourceT m c) -> m c+withMagickWandGenesis :: ResourceT IO c -> IO c withMagickWandGenesis f = bracket start finish (\_ -> runResourceT f) where start = liftIO F.magickWandGenesis finish = liftIO . const F.magickWandTerminus -- | Open a nested block inside genesis (for tracking nested resources)+localGenesis :: MonadBaseControl IO m => ResourceT m a -> m a localGenesis f = runResourceT f magickWand :: (MonadResource m) => m (ReleaseKey, Ptr MagickWand)
Graphics/ImageMagick/MagickWand/PixelWand.hs view
@@ -41,6 +41,7 @@ packCString, useAsCString) import Foreign hiding (void)+import Foreign.C.Types (CDouble) import qualified Graphics.ImageMagick.MagickWand.FFI.PixelWand as F import Graphics.ImageMagick.MagickWand.Types@@ -217,11 +218,16 @@ getYellow = (fmap realToFrac) . liftIO . F.pixelGetYellow ---+with3 ::+ (Ptr CDouble -> Ptr CDouble -> Ptr CDouble -> IO ())+ -> IO (CDouble, CDouble, CDouble) with3 f = alloca (\x -> alloca (\y -> alloca (\z -> do- f x y z+ _ <- f x y z x' <- peek x y' <- peek y z' <- peek z return (x',y',z') )))++map3 :: (a -> b) -> (a, a, a) -> (b, b, b) map3 f (a,b,c) = (f a, f b, f c)
Graphics/ImageMagick/MagickWand/WandImage.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE ScopedTypeVariables, CPP #-} module Graphics.ImageMagick.MagickWand.WandImage ( getImageHeight , getImageWidth@@ -330,6 +330,7 @@ ) where import Control.Applicative ((<$>))+import Control.Monad (void) import Control.Monad.IO.Class import Control.Monad.Trans.Resource import Data.ByteString (ByteString,@@ -344,7 +345,7 @@ import Data.Vector.Storable (Vector) import qualified Data.Vector.Storable as V import Filesystem.Path.CurrentOS-import Foreign+import Foreign hiding (void) import Foreign.C.Types import Graphics.ImageMagick.MagickCore.Types import qualified Graphics.ImageMagick.MagickWand.FFI.MagickWand as F@@ -490,10 +491,10 @@ -> Maybe (FilePath) -> m () writeImage w Nothing = withException_ w $ F.magickWriteImage w nullPtr-writeImage w (Just fn) = withException_ w $ useAsCString (encode fn) (\f -> F.magickWriteImage w f)+writeImage w (Just fn) = withException_ w $ useAsCString (_toBS $ encode fn) (\f -> F.magickWriteImage w f) writeImages :: (MonadResource m) => Ptr MagickWand -> FilePath -> Bool -> m ()-writeImages w fn b = withException_ w $ useAsCString (encode fn) (\f -> F.magickWriteImages w f (toMBool b))+writeImages w fn b = withException_ w $ useAsCString (_toBS $ encode fn) (\f -> F.magickWriteImages w f (toMBool b)) -- | MagickBlurImage() blurs an image. We convolve the image with a gaussian -- operator of the given radius and standard deviation (sigma). For reasonable@@ -871,7 +872,7 @@ -- | Reads an image or image sequence. The images are inserted at -- the current image pointer position readImage :: (MonadResource m) => Ptr MagickWand -> FilePath -> m ()-readImage w fn = withException_ w $ useAsCString (encode fn) (F.magickReadImage w)+readImage w fn = withException_ w $ useAsCString (_toBS $ encode fn) (F.magickReadImage w) -- | Reads an image or image sequence from a blob readImageBlob :: (MonadResource m) => PMagickWand -> ByteString -> m ()@@ -904,3 +905,12 @@ -- | Sets image Type setImageType :: (MonadResource m) => PMagickWand -> ImageType -> m () setImageType w imageType = withException_ w $ F.magickSetImageType w imageType+++-- | Convert system specific filepath to bytestring+_toBS = +#if defined(CABAL_OS_WINDOWS) || defined(CABAL_OS_DARWIN)+ encodeUTF8+#else+ id+#endif
imagemagick.cabal view
@@ -1,5 +1,5 @@ Name: imagemagick-Version: 0.0.2+Version: 0.0.3 Synopsis: bindings to imagemagick library License: OtherLicense License-file: LICENSE@@ -20,7 +20,6 @@ Exposed-modules: Graphics.ImageMagick.MagickCore , Graphics.ImageMagick.MagickCore.FFI.Gem , Graphics.ImageMagick.MagickCore.FFI.Log- , Graphics.ImageMagick.MagickCore.FFI.MagickCore , Graphics.ImageMagick.MagickCore.FFI.Mime , Graphics.ImageMagick.MagickCore.FFI.Option , Graphics.ImageMagick.MagickCore.Types.FFI.CacheView@@ -73,10 +72,16 @@ , bytestring >= 0.9 && <0.11 , text == 0.11.* , system-filepath == 0.4.*+ , MonadCatchIO-transformers == 0.3.* extensions: EmptyDataDecls Ghc-options: -Wall pkgconfig-depends: ImageMagick, MagickWand Build-tools: hsc2hs+ if os(windows)+ cpp-options: -DCABAL_OS_WINDOWS+ if os(darwin)+ cpp-options: -DCABAL_OS_DARWIN+ executable resize