imagemagick 0.0.1 → 0.0.2
raw patch · 13 files changed
+2269/−1 lines, 13 files
Files
- Graphics/ImageMagick/MagickCore/Gem.hs +45/−0
- Graphics/ImageMagick/MagickCore/Mime.hs +23/−0
- Graphics/ImageMagick/MagickCore/Option.hs +14/−0
- Graphics/ImageMagick/MagickCore/Types.hs +25/−0
- Graphics/ImageMagick/MagickWand/DrawingWand.hs +406/−0
- Graphics/ImageMagick/MagickWand/MagickWand.hs +348/−0
- Graphics/ImageMagick/MagickWand/PixelIterator.hs +92/−0
- Graphics/ImageMagick/MagickWand/PixelPacket.hs +48/−0
- Graphics/ImageMagick/MagickWand/PixelWand.hs +227/−0
- Graphics/ImageMagick/MagickWand/Types.hs +81/−0
- Graphics/ImageMagick/MagickWand/Utils.hs +41/−0
- Graphics/ImageMagick/MagickWand/WandImage.hs +906/−0
- imagemagick.cabal +13/−1
+ Graphics/ImageMagick/MagickCore/Gem.hs view
@@ -0,0 +1,45 @@+module Graphics.ImageMagick.MagickCore.Gem+ ( convertHSBToRGB+ , convertHSLToRGB+ , convertHWBToRGB+ , convertRGBToHSB+ , convertRGBToHSL+ , convertRGBToHWB+ ) where++import Foreign.Storable (peek)+import Foreign.Marshal.Alloc (alloca)+import Control.Monad.IO.Class+import Control.Monad.Trans.Resource+import Graphics.ImageMagick.MagickCore.Types+import qualified Graphics.ImageMagick.MagickCore.FFI.Gem as F+++with3 f = alloca (\x -> alloca (\y -> alloca (\z -> do + f x y z + x' <- peek x+ y' <- peek y+ z' <- peek z+ return (x',y',z')+ )))+map3 f (a,b,c) = (f a, f b, f c)+++convertHSBToRGB :: MonadResource m => Double -> Double -> Double -> m (Quantum, Quantum, Quantum)+convertHSBToRGB d1 d2 d3 = liftIO $ with3 (F.convertHSBToRGB (realToFrac d1) (realToFrac d2) (realToFrac d3))++convertHSLToRGB :: MonadResource m => Double -> Double -> Double -> m (Quantum, Quantum, Quantum)+convertHSLToRGB d1 d2 d3 = liftIO $ with3 (F.convertHSLToRGB (realToFrac d1) (realToFrac d2) (realToFrac d3))++convertHWBToRGB :: MonadResource m => Double -> Double -> Double -> m (Quantum, Quantum, Quantum)+convertHWBToRGB d1 d2 d3 = liftIO $ with3 (F.convertHWBToRGB (realToFrac d1) (realToFrac d2) (realToFrac d3))++convertRGBToHSB :: MonadResource m => Quantum -> Quantum -> Quantum -> m (Double, Double, Double)+convertRGBToHSB q1 q2 q3 = (liftIO $ with3 (F.convertRGBToHSB q1 q2 q3)) >>= return . (map3 realToFrac)++convertRGBToHSL :: MonadResource m => Quantum -> Quantum -> Quantum -> m (Double, Double, Double)+convertRGBToHSL q1 q2 q3 = liftIO $ with3 (F.convertRGBToHSL q1 q2 q3) >>= return . (map3 realToFrac)++convertRGBToHWB :: MonadResource m => Quantum -> Quantum -> Quantum -> m (Double, Double, Double)+convertRGBToHWB q1 q2 q3 = liftIO $ with3 (F.convertRGBToHSB q1 q2 q3) >>= return . (map3 realToFrac)+
+ Graphics/ImageMagick/MagickCore/Mime.hs view
@@ -0,0 +1,23 @@+module Graphics.ImageMagick.MagickCore.Mime+ ( toMime+ ) where++import Control.Applicative+import Control.Monad.IO.Class+import Control.Monad.Trans.Resource+import Data.ByteString (packCString,+ useAsCString)+import Data.Text (Text)+import Data.Text.Encoding (decodeUtf8,+ encodeUtf8)+import Foreign+++import qualified Graphics.ImageMagick.MagickCore.FFI.Mime as F++toMime :: (MonadResource m) => Text -> m Text+toMime format = liftIO $ do+ cstr <- useAsCString (encodeUtf8 format) F.magickToMime+ mime <- decodeUtf8 <$> packCString cstr+ free cstr+ return mime
+ Graphics/ImageMagick/MagickCore/Option.hs view
@@ -0,0 +1,14 @@+module Graphics.ImageMagick.MagickCore.Option+ ( parseChannelOption+ ) where++import Control.Monad.IO.Class+import Control.Monad.Trans.Resource+import Data.ByteString (ByteString, useAsCString)++import qualified Graphics.ImageMagick.MagickCore.FFI.Option as F+import Graphics.ImageMagick.MagickCore.Types+++parseChannelOption :: (MonadResource m) => ByteString -> m ChannelType+parseChannelOption s = liftIO $ useAsCString s F.parseChannelOption
+ Graphics/ImageMagick/MagickCore/Types.hs view
@@ -0,0 +1,25 @@+module Graphics.ImageMagick.MagickCore.Types+ ( module X+ ) where++import Graphics.ImageMagick.MagickCore.Types.FFI.AlphaChannelType as X+import Graphics.ImageMagick.MagickCore.Types.FFI.CacheView as X+import Graphics.ImageMagick.MagickCore.Types.FFI.ChannelType as X+import Graphics.ImageMagick.MagickCore.Types.FFI.ColorspaceType as X+import Graphics.ImageMagick.MagickCore.Types.FFI.Composite as X+import Graphics.ImageMagick.MagickCore.Types.FFI.Compress as X+import Graphics.ImageMagick.MagickCore.Types.FFI.Constitute as X+import Graphics.ImageMagick.MagickCore.Types.FFI.Distort as X+import Graphics.ImageMagick.MagickCore.Types.FFI.Exception as X+import Graphics.ImageMagick.MagickCore.Types.FFI.FilterTypes as X+import Graphics.ImageMagick.MagickCore.Types.FFI.Fx as X+import Graphics.ImageMagick.MagickCore.Types.FFI.Geometry as X+import Graphics.ImageMagick.MagickCore.Types.FFI.Image as X+import Graphics.ImageMagick.MagickCore.Types.FFI.Layer as X+import Graphics.ImageMagick.MagickCore.Types.FFI.Log as X+import Graphics.ImageMagick.MagickCore.Types.FFI.MagickFunction as X+import Graphics.ImageMagick.MagickCore.Types.FFI.PaintMethod as X+import Graphics.ImageMagick.MagickCore.Types.FFI.PixelPacket as X+import Graphics.ImageMagick.MagickCore.Types.FFI.Statistic as X+import Graphics.ImageMagick.MagickCore.Types.FFI.Types as X+import Graphics.ImageMagick.MagickCore.Types.MBits as X
+ Graphics/ImageMagick/MagickWand/DrawingWand.hs view
@@ -0,0 +1,406 @@+module Graphics.ImageMagick.MagickWand.DrawingWand+ ( drawingWand+ , getFillColor+ , setFillColor+ , setFillPatternURL+ , setFillRule+ , setFont+ , setFontSize+ , setGravity+ , setStrokeAntialias+ , setStrokeColor+ , setStrokeDashArray+ , setStrokeLineCap+ , setStrokeLineJoin+ , setStrokeOpacity+ , setStrokeWidth+ , setTextAntialias+ , drawAnnotation+ , drawCircle+ , drawComposite+ , drawEllipse+ , drawLine+ , drawPoint+ , drawPolygon+ , drawRectangle+ , drawRoundRectangle+ , drawColor+ , pushDrawingWand+ , popDrawingWand+ , rotate+ , translate+ , pushPattern+ , popPattern+-- , clearDrawingWand +-- , cloneDrawingWand +-- , destroyDrawingWand +-- , drawAffine +-- , drawAnnotation +-- , drawArc +-- , drawBezier +-- , drawCircle +-- , drawClearException +-- , drawComposite +-- , drawColor +-- , drawComment +-- , drawEllipse +-- , drawGetBorderColor +-- , drawGetClipPath +-- , drawGetClipRule +-- , drawGetClipUnits +-- , drawGetException +-- , drawGetExceptionType +-- , drawGetFillOpacity +-- , drawGetFillRule +-- , drawGetFont +-- , drawGetFontFamily +-- , drawGetFontResolution +-- , drawGetFontSize +-- , drawGetFontStretch +-- , drawGetFontStyle +-- , drawGetFontWeight +-- , drawGetGravity +-- , drawGetOpacity +-- , drawGetStrokeAntialias +-- , drawGetStrokeColor +-- , drawGetStrokeDashArray +-- , drawGetStrokeDashOffset +-- , drawGetStrokeLineJoin +-- , drawGetStrokeMiterLimit +-- , drawGetStrokeOpacity +-- , drawGetStrokeWidth +-- , drawGetTextAlignment +-- , drawGetTextAntialias +-- , drawGetTextDecoration +-- , drawGetTextEncoding +-- , drawGetTextKerning +-- , drawGetTextInterlineSpacing +-- , drawGetTextInterwordSpacing +-- , drawGetVectorGraphics +-- , drawGetTextUnderColor +-- , drawLine +-- , drawMatte +-- , drawPathClose +-- , drawPathCurveToAbsolute +-- , drawPathCurveToRelative +-- , drawPathCurveToQuadraticBezierAbsolute +-- , drawPathCurveToQuadraticBezierRelative +-- , drawPathCurveToQuadraticBezierSmoothAbsolute +-- , drawPathCurveToQuadraticBezierSmoothRelative +-- , drawPathCurveToSmoothAbsolute +-- , drawPathCurveToSmoothRelative +-- , drawPathEllipticArcAbsolute +-- , drawPathEllipticArcRelative +-- , drawPathFinish +-- , drawPathLineToAbsolute +-- , drawPathLineToRelative +-- , drawPathLineToHorizontalAbsolute +-- , drawPathLineToHorizontalRelative +-- , drawPathLineToVerticalAbsolute +-- , drawPathLineToVerticalRelative +-- , drawPathMoveToAbsolute +-- , drawPathMoveToRelative +-- , drawPathStart +-- , drawPoint +-- , drawPolygon +-- , drawPolyline +-- , drawPopClipPath +-- , drawPopDefs +-- , drawPopPattern +-- , drawPushClipPath +-- , drawPushDefs +-- , drawPushPattern +-- , drawRectangle +-- , drawResetVectorGraphics +-- , drawRotate +-- , drawRoundRectangle +-- , drawScale +-- , drawSetBorderColor +-- , drawSetClipPath +-- , drawSetClipRule +-- , drawSetClipUnits +-- , drawSetFillColor +-- , drawSetFillOpacity +-- , drawSetFontResolution +-- , drawSetOpacity +-- , drawSetFillPatternURL +-- , drawSetFillRule +-- , drawSetFontFamily +-- , drawSetFontSize +-- , drawSetFontStretch +-- , drawSetFontStyle +-- , drawSetFontWeight +-- , drawSetGravity +-- , drawSetStrokeColor +-- , drawSetStrokePatternURL +-- , drawSetStrokeAntialias +-- , drawSetStrokeDashArray +-- , drawSetStrokeDashOffset +-- , drawSetStrokeLineCap +-- , drawSetStrokeLineJoin +-- , drawSetStrokeMiterLimit +-- , drawSetStrokeOpacity +-- , drawSetStrokeWidth +-- , drawSetTextAlignment +-- , drawSetTextAntialias +-- , drawSetTextDecoration +-- , drawSetTextEncoding +-- , drawSetTextKerning +-- , drawSetTextInterlineSpacing +-- , drawSetTextInterwordSpacing +-- , drawSetTextUnderColor +-- , drawSetVectorGraphics +-- , drawSkewX +-- , drawSkewY +-- , drawTranslate +-- , drawSetViewbox +-- , isDrawingWand +-- , newDrawingWand +-- , peekDrawingWand +-- , popDrawingWand +-- , pushDrawingWand]+ ) where++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.C.Types ()+import Graphics.ImageMagick.MagickCore.Types+import qualified Graphics.ImageMagick.MagickWand.FFI.DrawingWand as F+import Graphics.ImageMagick.MagickWand.FFI.Types+import Graphics.ImageMagick.MagickWand.Types+import Graphics.ImageMagick.MagickWand.Utils+++drawingWand :: (MonadResource m) => m (ReleaseKey, PDrawingWand)+drawingWand = allocate (F.newDrawingWand) (void . F.destroyDrawingWand)++-- | returns the fill color used for drawing filled objects.+getFillColor :: (MonadResource m) => PDrawingWand -> PPixelWand -> m ()+getFillColor = (liftIO .). F.drawGetFillColor+++-- | DrawSetFillColor() sets the fill color to be used for drawing filled objects.+setFillColor :: (MonadResource m) => PDrawingWand -> PPixelWand -> m ()+setFillColor = (liftIO .). F.drawSetFillColor++-- | Sets the URL to use as a fill pattern+-- for filling objects. Only local URLs ("#identifier") are supported+-- at this time. These local URLs are normally created by defining a named+-- fill pattern with `pushPattern`/`popPattern`.+setFillPatternURL :: (MonadResource m) => PDrawingWand -> Text -> m ()+setFillPatternURL dw url = withException_ dw $! useAsCString (encodeUtf8 url) (F.drawSetFillPatternURL dw)++-- | Sets the fill rule to use while drawing polygons.+setFillRule :: (MonadResource m) => PDrawingWand -> FillRule -> m ()+setFillRule = (liftIO .). F.drawSetFillRule++-- | Sets the fully-sepecified font to use when annotating with text.+setFont :: (MonadResource m) => PDrawingWand -> ByteString -> m ()+setFont dw s = liftIO $ useAsCString s (F.drawSetFont dw)++-- | Sets the font pointsize to use when annotating with text.+setFontSize :: (MonadResource m) => PDrawingWand -> Double -> m ()+setFontSize dw size = liftIO $ F.drawSetFontSize dw (realToFrac size)++-- | Sets the text placement gravity to use when annotating with text.+setGravity :: (MonadResource m) => PDrawingWand -> GravityType -> m ()+setGravity = (liftIO .). F.drawSetGravity++setStrokeAntialias :: (MonadResource m) => PDrawingWand -> Bool -> m ()+setStrokeAntialias dw antialias = liftIO $ F.drawSetStrokeAntialias dw (toMBool antialias)++-- | sets the color used for stroking object outlines.+setStrokeColor :: (MonadResource m) => PDrawingWand -> PPixelWand -> m ()+setStrokeColor = (liftIO .). F.drawSetStrokeColor++-- | Specifies the pattern of dashes and gaps used to+-- stroke paths. The stroke dash array represents an array of numbers that+-- specify the lengths of alternating dashes and gaps in pixels. If an odd+-- number of values is provided, then the list of values is repeated to yield+-- an even number of values. To remove an existing dash array, pass an emtpy list.+-- A typical stroke dash array might contain the members 5 3 2.+setStrokeDashArray :: (MonadResource m) => PDrawingWand -> [Double] -> m ()+setStrokeDashArray dw [] = liftIO $ F.drawSetStrokeDashArray dw 0 nullPtr+setStrokeDashArray dw dashes = liftIO $ withArray (map realToFrac dashes) $ \arr ->+ F.drawSetStrokeDashArray dw (fromIntegral $ length dashes) arr++-- | Specifies the shape to be used at the end of open subpaths+-- when they are stroked. Values of `LineCap` are `undefinedCap`,+-- `buttCap, `roundCap` and `squareCap`.+setStrokeLineCap :: (MonadResource m) => PDrawingWand -> LineCap -> m ()+setStrokeLineCap = (liftIO .). F.drawSetStrokeLineCap++-- | Specifies the shape to be used at the corners of paths+-- (or other vector shapes) when they are stroked.+-- Values of `LineJoin` are `undefinedJoin`, `miterJoin`, `roundJoin` and `bevelJoin`.+setStrokeLineJoin :: (MonadResource m) => PDrawingWand -> LineJoin -> m ()+setStrokeLineJoin = (liftIO .). F.drawSetStrokeLineJoin++-- | specifies the opacity of stroked object outlines.+setStrokeOpacity :: (MonadResource m) => PDrawingWand -> Double -> m ()+setStrokeOpacity dw op = liftIO $ F.drawSetStrokeOpacity dw (realToFrac op)++-- | sets the width of the stroke used to draw object outlines.+setStrokeWidth :: (MonadResource m) => PDrawingWand -> Double -> m ()+setStrokeWidth dw width = liftIO $ F.drawSetStrokeWidth dw (realToFrac width)++-- | Controls whether text is antialiased. Text is antialiased by default.+setTextAntialias :: (MonadResource m) => PDrawingWand -> Bool -> m ()+setTextAntialias dw antialias = liftIO $ F.drawSetTextAntialias dw (toMBool antialias)++-- | Draws text on the image.+drawAnnotation :: (MonadResource m) => PDrawingWand+ -> Double -- ^ x ordinate to left of text+ -> Double -- ^ y ordinate to text baseline+ -> Text -- ^ text to draw+ -> m ()+drawAnnotation dw x y txt = liftIO $ useAsCString (encodeUtf8 txt)+ (\cstr -> F.drawAnnotation dw (realToFrac x) (realToFrac y) cstr)++-- | Draws a circle on the image.+drawCircle :: (MonadResource m) => PDrawingWand+ -> Double -- ^ origin x ordinate+ -> Double -- ^ origin y ordinate+ -> Double -- ^ perimeter x ordinate+ -> Double -- ^ perimeter y ordinate+ -> m ()+drawCircle dw ox oy px py = liftIO $ F.drawCircle dw (realToFrac ox) (realToFrac oy)+ (realToFrac px) (realToFrac py)++-- | Composites an image onto the current image, using the specified+-- composition operator, specified position, and at the specified size.+drawComposite :: (MonadResource m) => PDrawingWand+ -> CompositeOperator -- ^ composition operator+ -> Double -- ^ x ordinate of top left corner+ -> Double -- ^ y ordinate of top left corner+ -> Double -- ^ width to resize image to prior to compositing, specify zero to use existing width+ -> Double -- ^ height to resize image to prior to compositing, specify zero to use existing height+ -> PMagickWand -- ^ image to composite is obtained from this wand+ -> m ()+drawComposite dw compose x y w h dw' = withException_ dw $! F.drawComposite dw compose+ (realToFrac x) (realToFrac y)+ (realToFrac w) (realToFrac h) dw'++-- | Draws an ellipse on the image.+drawEllipse :: (MonadResource m) => PDrawingWand+ -> Double -- ^ origin x ordinate+ -> Double -- ^ origin y ordinate+ -> Double -- ^ radius in x+ -> Double -- ^ radius in y+ -> Double -- ^ starting rotation in degrees+ -> Double -- ^ ending rotation in degrees+ -> m ()+drawEllipse dw ox oy rx ry start end = liftIO $ F.drawEllipse dw (realToFrac ox) (realToFrac oy)+ (realToFrac rx) (realToFrac ry)+ (realToFrac start) (realToFrac end)++-- | Draws a line on the image using the current stroke color,+-- stroke opacity, and stroke width.+drawLine :: (MonadResource m) => PDrawingWand+ -> Double -- ^ starting x ordinate+ -> Double -- ^ starting y ordinate+ -> Double -- ^ ending x ordinate+ -> Double -- ^ ending y ordinate+ -> m ()+drawLine dw sx sy ex ey = liftIO $ F.drawLine dw (realToFrac sx) (realToFrac sy)+ (realToFrac ex) (realToFrac ey)++-- | Draws a polygon using the current stroke, stroke width,+-- and fill color or texture, using the specified array of coordinates.+drawPolygon :: (MonadResource m) => PDrawingWand+ -> [PointInfo] -- ^ coordinates+ -> m ()+drawPolygon dw points = liftIO $ withArrayLen points $ \len arr ->+ F.drawPolygon dw (fromIntegral len) arr++-- | Draws a rectangle given two coordinates+-- and using the current stroke, stroke width, and fill settings.+drawRectangle :: (MonadResource m) => PDrawingWand+ -> Double -- ^ x ordinate of first coordinate+ -> Double -- ^ y ordinate of first coordinate+ -> Double -- ^ x ordinate of second coordinate+ -> Double -- ^ y ordinate of second coordinate+ -> m ()+drawRectangle dw x1 y1 x2 y2 = liftIO $ F.drawRectangle dw (realToFrac x1) (realToFrac y1)+ (realToFrac x2) (realToFrac y2)++-- | DrawRoundRectangle() draws a rounted rectangle given two coordinates,+-- x & y corner radiuses and using the current stroke, stroke width, and fill settings.+drawRoundRectangle :: (MonadResource m) => PDrawingWand+ -> Double -- ^ x ordinate of first coordinate+ -> Double -- ^ y ordinate of first coordinate+ -> Double -- ^ x ordinate of second coordinate+ -> Double -- ^ y ordinate of second coordinate+ -> Double -- ^ radius of corner in horizontal direction+ -> Double -- ^ radius of corner in vertical direction+ -> m ()+drawRoundRectangle p x1 y1 x2 y2 rx ry = liftIO $ F.drawRoundRectangle p (realToFrac x1)+ (realToFrac y1)+ (realToFrac x2)+ (realToFrac y2)+ (realToFrac rx)+ (realToFrac ry)+-- | Clones the current drawing wand to create a new drawing wand.+-- The original drawing wand(s) may be returned to by invoking `popDrawingWand`.+-- The drawing wands are stored on a drawing wand stack. For every Pop there must+-- have already been an equivalent Push.+pushDrawingWand :: (MonadResource m) => PDrawingWand -> m ()+pushDrawingWand dw = withException_ dw $ F.pushDrawingWand dw++-- | Destroys the current drawing wand and returns to the+-- previously pushed drawing wand. Multiple drawing wands may exist.+-- It is an error to attempt to pop more drawing wands than have been pushed,+-- and it is proper form to pop all drawing wands which have been pushed.+popDrawingWand :: (MonadResource m) => PDrawingWand -> m ()+popDrawingWand dw = withException_ dw $ F.popDrawingWand dw++-- | Applies the specified rotation to the current coordinate space.+rotate :: (MonadResource m) => PDrawingWand -> Double -> m ()+rotate dw degrees = liftIO $ F.drawRotate dw (realToFrac degrees)++-- | Applies a translation to the current coordinate system+-- which moves the coordinate system origin to the specified coordinate.+translate :: (MonadResource m) => PDrawingWand -> Double -> Double -> m ()+translate dw x y = liftIO $ F.drawTranslate dw (realToFrac x) (realToFrac y)+++-- | Indicates that subsequent commands up to a `popPattern` command comprise+-- the definition of a named pattern. The pattern space is assigned top left+-- corner coordinates, a width and height, and becomes its own drawing space.+-- Anything which can be drawn may be used in a pattern definition.+-- Named patterns may be used as stroke or brush definitions.+pushPattern :: (MonadResource m) => PDrawingWand+ -> Text -- ^ pattern identification for later reference+ -> Double -- x ordinate of top left corner+ -> Double -- y ordinate of top left corner+ -> Double -- width of pattern space+ -> Double -- height of pattern space+ -> m ()+pushPattern dw name x y w h = withException_ dw $!+ useAsCString (encodeUtf8 name) (\cstr ->+ F.drawPushPattern dw cstr+ (realToFrac x) (realToFrac y)+ (realToFrac w) (realToFrac h))++-- | Terminates a pattern definition.+popPattern :: (MonadResource m) => PDrawingWand -> m ()+popPattern dw = withException_ dw $! F.drawPopPattern dw+++-- | DrawColor() draws color on image using the current fill color, starting at+-- specified position, and using specified paint method. The available paint methods are:+--+-- PointMethod: Recolors the target pixel+-- ReplaceMethod: Recolor any pixel that matches the target pixel.+-- FloodfillMethod: Recolors target pixels and matching neighbors.+-- ResetMethod: Recolor all pixels.+drawColor :: (MonadResource m) => PDrawingWand -> Double -> Double -> PaintMethod -> m ()+drawColor p x t m = liftIO $ F.drawColor p (realToFrac x) (realToFrac t) m++-- | Draws a point using the current fill color.+drawPoint :: (MonadResource m) => PDrawingWand -> Double -> Double -> m ()+drawPoint dw x y = liftIO $ F.drawPoint dw (realToFrac x) (realToFrac y)
+ Graphics/ImageMagick/MagickWand/MagickWand.hs view
@@ -0,0 +1,348 @@+{-# LANGUAGE FlexibleContexts #-}+module Graphics.ImageMagick.MagickWand.MagickWand+ ( withMagickWandGenesis+ , localGenesis+ -- * Creation+ , magickWand+ , wandResource+-- , magickWandFromImage+-- , isMagickWand+ , cloneMagickWand+-- , clearMagickWand+ , getSize+ , setSize+ , setImageArtifact+ , deleteImageArtifact+ , getIteratorIndex+ , setIteratorIndex+-- , setFirstIterator+-- , setLastIterator+ , resetIterator+ , magickIterate+ , magickIterateReverse+ , deleteOption+ , getOption+ , setOption+ , getOptions+ , deleteImageProperty+ , getImageProperty+ , setImageProperty+ , getImageProperties+ , getImageProfile+ , removeImageProfile+ , setImageProfile+ , getImageProfiles+-- , queryConfigureOption+-- , queryConfigureOptions+-- , queryFontMetrics+-- , queryMultilineFontMetrics+-- , queryFonts+-- , relinquishMemory+-- , deleteImageArtifact+-- , deleteImageProperty+-- , getAntialias+-- , getBackgroundColor+ , getColorspace+ , getCompression+ , getCompressionQuality+-- , getCopyright+-- , getFilename+-- , getFont+-- , getFormat+-- , getGravity+-- , getHomeURL+-- , getImageArtifact+ , getImageArtifacts+-- , getInterlaceScheme+-- , getInterpolateMethod+-- , getOrientation+-- , getPackageName+-- , getPage+-- , getPointsize+-- , getQuantumDepth+-- , getQuantumRange+-- , getReleaseDate+ , getImageResolution+-- , getResource+-- , getResourceLimit+-- , getSamplingFactors+-- , getSize+-- , getSizeOffset+-- , getType+-- , getVersion+-- , profileImage+-- , removeImageProfile+-- , setAntialias+-- , setBackgroundColor+ , setColorspace+ , setCompression+ , setCompressionQuality+-- , setDepth+-- , setExtract+-- , setFilename+-- , setFont+-- , setFormat+-- , setGravity+-- , setImageArtifact+-- , setImageProfile+-- , setInterlaceScheme+-- , setInterpolateMethod+-- , setOrientation+-- , setPage+-- , setPassphrase+-- , setPointsize+-- , setProgressMonitor+-- , setResourceLimit+ , setImageResolution+-- , setSamplingFactors+-- , setSizeOffset+-- , setType+ ) where++import Control.Applicative ((<$>))+import Control.Exception+import Control.Monad+import Control.Monad.IO.Class+import Control.Monad.Trans.Resource+import Data.ByteString+import Data.Text (Text)+import Data.Text.Encoding (decodeUtf8,+ encodeUtf8)+import Data.Vector.Storable (Vector)+import qualified Data.Vector.Storable as V+import Foreign hiding+ (void)+import Foreign.C.String+import Foreign.C.Types+import qualified Graphics.ImageMagick.MagickWand.FFI.MagickWand as F+import Graphics.ImageMagick.MagickWand.FFI.Types+import qualified Graphics.ImageMagick.MagickWand.FFI.WandProperties as F+import Graphics.ImageMagick.MagickWand.Types+import Graphics.ImageMagick.MagickWand.Utils++-- | Create magic wand environment and closes it at the+-- 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 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 f = runResourceT f++magickWand :: (MonadResource m) => m (ReleaseKey, Ptr MagickWand)+magickWand = wandResource F.newMagickWand++magickIterateF :: (MonadResource m) =>+ (PMagickWand -> IO ())+ -> (PMagickWand -> IO MagickBooleanType)+ -> PMagickWand -> (PMagickWand -> m ()) -> m ()+magickIterateF initF next w f = liftIO (initF w) >> go -- TODO: use fix+ where+ go = do+ i <- liftIO $ next w+ when (i==mTrue) $ f w >> go++magickIterate :: (MonadResource m) => Ptr MagickWand -> (Ptr MagickWand -> m ()) -> m ()+magickIterate = magickIterateF F.magickResetIterator F.magickNextImage++magickIterateReverse :: (MonadResource m) => Ptr MagickWand -> (Ptr MagickWand -> m ()) -> m ()+magickIterateReverse = magickIterateF F.magickSetLastIterator F.magickPreviousImage++wandResource :: (MonadResource m) => (IO (Ptr MagickWand)) -> m (ReleaseKey, Ptr MagickWand)+wandResource f = allocate f destroy+ where destroy = void . F.destroyMagickWand++cloneMagickWand :: (MonadResource m) => Ptr MagickWand -> m (ReleaseKey, Ptr MagickWand)+cloneMagickWand = wandResource . F.cloneMagickWand++setSize :: (MonadResource m) => Ptr MagickWand -> Int -> Int -> m ()+setSize w cols rows = withException_ w $ F.magickSetSize w (fromIntegral cols) (fromIntegral rows)++-- | Returns the size associated with the magick wand.+getSize :: (MonadResource m) => Ptr MagickWand -> m (Int, Int)+getSize w = liftIO $ alloca $ \pw -> do+ height <- alloca $ \ph -> F.magickGetSize w pw ph >> peek ph >>= return+ width <- peek pw+ return (fromIntegral width, fromIntegral height)+++-- | MagickSetImageArtifact() associates a artifact with an image.+-- The format of the MagickSetImageArtifact method is:+setImageArtifact :: (MonadResource m) => PMagickWand -> ByteString -> ByteString -> m () -- TODO use normal types+setImageArtifact w a v = withException_ w $ useAsCString a+ $ \a' -> useAsCString v+ $ F.magickSetImageArtifact w a'++-- | MagickDeleteImageArtifact() deletes a wand artifact.+deleteImageArtifact :: (MonadResource m) => PMagickWand -> ByteString -> m ()+deleteImageArtifact w a = withException_ w $ useAsCString a+ $ F.magickDeleteImageArtifact w++-- | Sets the iterator to the given position in the image list specified+-- with the index parameter. A zero index will set the first image as+-- current, and so on. Negative indexes can be used to specify an image+-- relative to the end of the images in the wand, with -1 being the last+-- image in the wand.+setIteratorIndex :: (MonadResource m) => Ptr MagickWand -> Int -> m ()+setIteratorIndex w i = withException_ w $ F.magickSetIteratorIndex w (fromIntegral i)++-- | Returns the position of the iterator in the image list.+getIteratorIndex :: (MonadResource m) => Ptr MagickWand -> m Int+getIteratorIndex w = liftIO $ fromIntegral <$> F.magickGetIteratorIndex w++resetIterator :: (MonadResource m) => Ptr MagickWand -> m ()+resetIterator = liftIO . F.magickResetIterator++getOption :: (MonadResource m) => Ptr MagickWand -> Text -> m Text+getOption w key = liftIO $ do+ cstr <- useAsCString (encodeUtf8 key) (F.magickGetOption w)+ value <- decodeUtf8 <$> packCString cstr+ F.magickRelinquishMemory (castPtr cstr)+ return value++-- | Associates one or options with the wand (e.g. setOption wand "jpeg:perserve" "yes").+deleteOption :: (MonadResource m) => Ptr MagickWand -> Text -> m ()+deleteOption w key =+ withException_ w $ useAsCString (encodeUtf8 key) (F.magickDeleteOption w)++-- | Associates one or options with the wand (e.g. setOption wand "jpeg:perserve" "yes").+setOption :: (MonadResource m) => Ptr MagickWand -> Text -> Text -> m ()+setOption w key value =+ withException_ w $ useAsCString (encodeUtf8 key) $+ \cstr -> useAsCString (encodeUtf8 value) (F.magickSetOption w cstr)++getOptions :: (MonadResource m) => Ptr MagickWand -> Text -> m [Text]+getOptions w pattern = liftIO $ alloca $ \pn -> do+ poptionps <- useAsCString (encodeUtf8 pattern) (\cstr -> F.magickGetOptions w cstr pn)+ n <- fromIntegral <$> peek pn+ optionps <- peekArray n poptionps+ options <- forM optionps $ \optionp -> do+ option <- decodeUtf8 <$> packCString optionp+ F.magickRelinquishMemory (castPtr optionp)+ return option+ F.magickRelinquishMemory (castPtr poptionps)+ return options++-- | Deletes a wand property+deleteImageProperty :: (MonadResource m) => Ptr MagickWand -> Text -> m ()+deleteImageProperty w prop =+ withException_ w $ useAsCString (encodeUtf8 prop) (F.magickDeleteImageProperty w)++-- | Returns a value associated with the specified property+getImageProperty :: (MonadResource m) => Ptr MagickWand -> Text -> m Text+getImageProperty w prop = liftIO $ do+ cstr <- useAsCString (encodeUtf8 prop) (F.magickGetImageProperty w)+ value <- decodeUtf8 <$> packCString cstr+ F.magickRelinquishMemory (castPtr cstr)+ return value++-- | Associates a property with an image.+setImageProperty :: (MonadResource m) => Ptr MagickWand -> Text -> Text -> m ()+setImageProperty w prop value =+ withException_ w $ useAsCString (encodeUtf8 prop) $+ \cstr -> useAsCString (encodeUtf8 value) (F.magickSetImageProperty w cstr)++-- | Returns all the property names that match the specified pattern associated+-- with a wand+getImageProperties :: (MonadResource m) => Ptr MagickWand -> Text -> m [Text]+getImageProperties w pattern = liftIO $ alloca $ \pn -> do+ ppropps <- useAsCString (encodeUtf8 pattern) (\cstr -> F.magickGetImageProperties w cstr pn)+ n <- fromIntegral <$> peek pn+ propps <- peekArray n ppropps+ props <- forM propps $ \propp -> do+ prop <- decodeUtf8 <$> packCString propp+ F.magickRelinquishMemory (castPtr propp)+ return prop+ F.magickRelinquishMemory (castPtr ppropps)+ return props++getProfile :: (MonadResource m) =>+ (PMagickWand -> CString -> Ptr CSize -> IO (Ptr Word8)) ->+ PMagickWand -> Text -> m (Vector Word8)+getProfile f w name = liftIO $ do+ (pprofile, len) <- alloca $ \pn -> useAsCString (encodeUtf8 name) $ \cstr -> do+ p <- f w cstr pn+ n <- fromIntegral <$> peek pn+ return (p,n)+ -- TODO: maybe we should use copyBytes instead?+ profile <- V.generateM len (peekElemOff pprofile)+ F.magickRelinquishMemory (castPtr pprofile)+ return profile++-- | Returns the named image profile.+getImageProfile :: (MonadResource m) => Ptr MagickWand -> Text -> m (Vector Word8)+getImageProfile = getProfile F.magickGetImageProfile++-- | Removes the named image profile and returns it+removeImageProfile :: (MonadResource m) => Ptr MagickWand -> Text -> m (Vector Word8)+removeImageProfile = getProfile F.magickRemoveImageProfile++-- | Adds a named profile to the magick wand. If a profile with the same+-- name already exists, it is replaced. This method differs from the+-- `profileImage` method in that it does not apply any CMS color profiles.+setImageProfile :: (MonadResource m) => Ptr MagickWand -> Text -> Vector Word8 -> m ()+setImageProfile w name profile =+ withException_ w $ useAsCString (encodeUtf8 name) $+ \cstr -> V.unsafeWith profile $+ \p -> (F.magickSetImageProfile w cstr) p (fromIntegral $ V.length profile)++-- | Returns all the profile names that match the specified pattern+-- associated with a wand.+getImageProfiles :: (MonadResource m) => Ptr MagickWand -> Text -> m [Text]+getImageProfiles w pattern = liftIO $ alloca $ \pn -> do+ pprofileps <- useAsCString (encodeUtf8 pattern) (\cstr -> F.magickGetImageProfiles w cstr pn)+ n <- fromIntegral <$> peek pn+ profileps <- peekArray n pprofileps+ profiles <- forM profileps $ \profilep -> do+ profile <- decodeUtf8 <$> packCString profilep+ F.magickRelinquishMemory (castPtr profilep)+ return profile+ F.magickRelinquishMemory (castPtr pprofileps)+ return profiles++-- | MagickGetColorspace() gets the wand colorspace type.+getColorspace :: (MonadResource m) => PMagickWand -> m ColorspaceType+getColorspace = liftIO . F.magickGetColorspace++-- | MagickSetColorspace() sets the wand colorspace type.+setColorspace :: (MonadResource m) => PMagickWand -> ColorspaceType -> m ()+setColorspace w c = withException_ w $ F.magickSetColorspace w c++getCompression :: (MonadResource m) => PMagickWand -> m CompressionType+getCompression = liftIO . F.magickGetCompression++setCompression :: (MonadResource m) => PMagickWand -> CompressionType -> m ()+setCompression w c = withException_ w $ F.magickSetCompression w c++getCompressionQuality :: (MonadResource m) => PMagickWand -> m Int+getCompressionQuality w = liftIO $ F.magickGetCompressionQuality w >>= return . fromIntegral++setCompressionQuality :: (MonadResource m) => PMagickWand -> Int -> m ()+setCompressionQuality w c = withException_ w $ F.magickSetCompressionQuality w (fromIntegral c)++getImageResolution :: (MonadResource m) => PMagickWand -> m (Double,Double)+getImageResolution w = liftIO $ alloca $ \py -> do+ x <- alloca $ \px -> withExceptionIO w $ do+ result <- F.magickGetImageResolution w px py+ value <- peek px+ return (result, value)+ y <- peek py+ return (realToFrac x, realToFrac y)++setImageResolution :: (MonadResource m) => PMagickWand -> Double -> Double -> m ()+setImageResolution w x y = withException_ w $ F.magickSetImageResolution w (realToFrac x) (realToFrac y)++getImageArtifacts :: (MonadResource m) => Ptr MagickWand -> Text -> m [Text]+getImageArtifacts w pattern = liftIO $ alloca $ \pn -> do+ partifactps <- useAsCString (encodeUtf8 pattern) (\cstr -> F.magickGetImageArtifacts w cstr pn)+ n <- fromIntegral <$> peek pn+ artifactps <- peekArray n partifactps+ artifacts <- forM artifactps $ \artifactp -> do+ artifact <- decodeUtf8 <$> packCString artifactp+ F.magickRelinquishMemory (castPtr artifactp)+ return artifact+ F.magickRelinquishMemory (castPtr partifactps)+ return artifacts
+ Graphics/ImageMagick/MagickWand/PixelIterator.hs view
@@ -0,0 +1,92 @@+module Graphics.ImageMagick.MagickWand.PixelIterator+ ( pixelIterator+ , pixelRegionIterator+ , pixelGetNextIteratorRow+ , pixelSyncIterator+ , pixelResetIterator+ , pixelIterateList+ , pixelGetMagickColor -- TODO move to another file+ , pixelSetMagickColor -- TODO move to another file+-- , clonePixelIterator +-- , isPixelIterator +-- , pixelGetCurrentIteratorRow +-- , pixelGetIteratorRow +-- , pixelGetNextIteratorRow +-- , pixelGetPreviousIteratorRow +-- , pixelSetFirstIteratorRow +-- , pixelSetIteratorRow +-- , pixelSetLastIteratorRow + ) where++import Control.Monad+import Control.Monad.IO.Class+import Control.Monad.Trans.Resource+import Data.Vector.Storable (Vector)+import qualified Data.Vector.Storable as V+import Foreign hiding (void)+import Foreign.C.Types (CSize)+import System.IO.Unsafe (unsafeInterleaveIO)++import qualified Graphics.ImageMagick.MagickWand.FFI.PixelIterator as F+import qualified Graphics.ImageMagick.MagickWand.FFI.PixelWand as F+import Graphics.ImageMagick.MagickWand.FFI.Types+import Graphics.ImageMagick.MagickWand.Types+import Graphics.ImageMagick.MagickWand.Utils+++pixelIterator :: (MonadResource m) => Ptr MagickWand -> m (ReleaseKey, PPixelIterator)+pixelIterator w = allocate (F.newPixelIterator w) destroy+ where destroy = void . F.destroyPixelIterator++pixelRegionIterator :: (MonadResource m)+ => Ptr MagickWand -> Int -> Int -> Int -> Int -> m (ReleaseKey, PPixelIterator)+pixelRegionIterator w x y width height = allocate (F.newPixelRegionIterator w x' y' width' height') destroy+ where destroy = void . F.destroyPixelIterator+ x' = fromIntegral x+ y' = fromIntegral y+ width' = fromIntegral width+ height' = fromIntegral height++pixelGetNextIteratorRow :: (MonadResource m) => PPixelIterator -> m (Maybe (Vector PPixelWand))+pixelGetNextIteratorRow p = do+ x <- allocate (createPixelWandVector (F.pixelGetNextIteratorRow p)) (const $ return ())+ case x of+ (_, Just v) -> return (Just v)+ (_, Nothing) -> return Nothing++pixelGetMagickColor :: (MonadIO m) => PPixelWand -> m PMagickPixelPacket+pixelGetMagickColor w = liftIO $ do+ c <- mallocForeignPtr+ withForeignPtr c (F.pixelGetMagickColor w)+ return c++pixelSetMagickColor :: (MonadResource m) => PPixelWand -> PMagickPixelPacket -> m ()+pixelSetMagickColor w c = liftIO $ withForeignPtr c (F.pixelSetMagickColor w)++pixelSyncIterator :: (MonadResource m) => PPixelIterator -> m ()+pixelSyncIterator p = withException_ p $ F.pixelSyncIterator p++pixelResetIterator :: (MonadResource m) => PPixelIterator -> m ()+pixelResetIterator = liftIO . F.pixelResetIterator++-- | creates lazy list of pixel vectors+pixelIterateList :: (MonadResource m) => PPixelIterator -> m [Vector PPixelWand]+pixelIterateList it = pixelResetIterator it >> liftIO go+ where+ go :: IO [Vector PPixelWand]+ go = unsafeInterleaveIO $ do+ mv <- createPixelWandVector (F.pixelGetNextIteratorRow it)+ case mv of+ Just v -> go >>= return . (:) v+ Nothing -> return []+++createPixelWandVector :: (Ptr CSize -> IO (Ptr PPixelWand)) -> IO (Maybe (Vector (PPixelWand)))+createPixelWandVector f = alloca $ \x -> do+ ptr <- f x+ if ptr == nullPtr+ then return Nothing+ else do+ n <- fmap fromIntegral (peek x)+ fmap (Just . (\p -> V.unsafeFromForeignPtr0 p n)) (newForeignPtr_ ptr)+
+ Graphics/ImageMagick/MagickWand/PixelPacket.hs view
@@ -0,0 +1,48 @@+module Graphics.ImageMagick.MagickWand.PixelPacket+ ( getPixelRed+ , setPixelRed+ , getPixelBlue+ , setPixelBlue+ , getPixelGreen+ , setPixelGreen+ , getPixelIndex+ , setPixelIndex+ ) where++import Control.Monad.IO.Class+import Foreign+import qualified Graphics.ImageMagick.MagickWand.FFI.Types as F+import Graphics.ImageMagick.MagickWand.Types+++getPixel' :: (MonadIO m) => (Ptr F.MagickPixelPacket -> IO MagickRealType) -> PMagickPixelPacket -> m MagickRealType+getPixel' f wp = liftIO $ withForeignPtr wp f+{-# INLINE getPixel' #-}++getPixelRed :: (MonadIO m) => PMagickPixelPacket -> m MagickRealType+getPixelRed = getPixel' F.getPixelRed++getPixelBlue :: (MonadIO m) => PMagickPixelPacket -> m MagickRealType+getPixelBlue = getPixel' F.getPixelBlue++getPixelGreen :: (MonadIO m) => PMagickPixelPacket -> m MagickRealType+getPixelGreen = getPixel' F.getPixelGreen++getPixelIndex :: (MonadIO m) => PMagickPixelPacket -> m MagickRealType+getPixelIndex = getPixel' F.getPixelIndex++setPixel' :: (MonadIO m) => (Ptr F.MagickPixelPacket -> MagickRealType -> IO ()) -> PMagickPixelPacket -> MagickRealType -> m ()+setPixel' f wp c = liftIO $ withForeignPtr wp (`f` c)+{-# INLINE setPixel' #-}++setPixelRed :: (MonadIO m) => PMagickPixelPacket -> MagickRealType -> m ()+setPixelRed = setPixel' F.setPixelRed++setPixelIndex :: (MonadIO m) => PMagickPixelPacket -> MagickRealType -> m ()+setPixelIndex = setPixel' F.setPixelIndex++setPixelGreen :: (MonadIO m) => PMagickPixelPacket -> MagickRealType -> m ()+setPixelGreen = setPixel' F.setPixelGreen++setPixelBlue :: (MonadIO m) => PMagickPixelPacket -> MagickRealType -> m ()+setPixelBlue = setPixel' F.setPixelBlue
+ Graphics/ImageMagick/MagickWand/PixelWand.hs view
@@ -0,0 +1,227 @@+{-# LANGUAGE CPP #-}+module Graphics.ImageMagick.MagickWand.PixelWand+ ( pixelWand+-- , clearPixelWand+-- , cloneWand+-- , cloneWands+ , isPixelWandSimilar+-- , isPixelWand+ , setColorCount, getColorCount+ -- ** Literal names+ , setColor+ , getColorAsString, getColorAsNormalizedString+ -- HSL+ , getHSL, setHSL+ , getMagickColor, setMagickColor+ , setColorFromWand+ , getQuantumColor, setQuantumColor+ -- ** Color parts+ -- Index+ , getIndex, setIndex+ -- Fuzz+ , getFuzz, setFuzz+ -- Alpha+ , getOpacity, getOpacityQuantum, setOpacity, setOpacityQuantum+ , getAlpha, getAlphaQuantum, setAlpha, setAlphaQuantum+ -- RGB+ , getRed, getRedQuantum, setRed, setRedQuantum+ , getBlue, getBlueQuantum, setBlue, setBlueQuantum+ , getGreen, getGreenQuantum, setGreen, setGreenQuantum+ -- CMYK+ , getCyan, getCyanQuantum, setCyan, setCyanQuantum+ , getMagenta, getMagentaQuantum, setMagenta, setMagentaQuantum+ , getYellow, getYellowQuantum, setYellow, setYellowQuantum+ , getBlack, getBlackQuantum, setBlack, setBlackQuantum+ ) where++import Control.Monad (void)+import Control.Monad.IO.Class+import Control.Monad.Trans.Resource+import Data.ByteString (ByteString,+ packCString,+ useAsCString)+import Foreign hiding (void)++import qualified Graphics.ImageMagick.MagickWand.FFI.PixelWand as F+import Graphics.ImageMagick.MagickWand.Types+import Graphics.ImageMagick.MagickWand.Utils++pixelWand :: (MonadResource m) => m PPixelWand+pixelWand = fmap snd (allocate F.newPixelWand destroy)+ where destroy = void . F.destroyPixelWand++setColor :: (MonadResource m) => PPixelWand -> ByteString -> m ()+setColor p s = withException_ p $ useAsCString s (F.pixelSetColor p)+++getMagickColor :: (MonadResource m) => PPixelWand -> m PMagickPixelPacket+getMagickColor w = liftIO $ do+ p <- mallocForeignPtr+ withForeignPtr p (F.pixelGetMagickColor w)+ return p++setMagickColor :: (MonadResource m) => PPixelWand -> PMagickPixelPacket -> m ()+setMagickColor w p = liftIO $ withForeignPtr p (F.pixelSetMagickColor w)++setColorCount :: (MonadResource m) => PPixelWand -> Int -> m ()+setColorCount w i = liftIO $ F.pixelSetColorCount w (fromIntegral i)++getColorCount :: (MonadResource m) => PPixelWand -> m Int+getColorCount w = liftIO (F.pixelGetColorCount w) >>= return . fromIntegral++getColorAsString :: (MonadResource m) => PPixelWand -> m ByteString+getColorAsString w = liftIO $ F.pixelGetColorAsString w >>= packCString++getColorAsNormalizedString :: (MonadResource m) => PPixelWand -> m ByteString+getColorAsNormalizedString w = liftIO $ F.pixelGetColorAsNormalizedString w >>= packCString++getHSL :: (MonadResource m) => PPixelWand -> m (Double, Double, Double)+getHSL w = liftIO $ fmap (map3 realToFrac) (with3 (F.pixelGetHSL w))++setHSL :: (MonadResource m) => PPixelWand -> Double -> Double -> Double -> m ()+setHSL w h s l = liftIO $ F.pixelSetHSL w (realToFrac h) (realToFrac s) (realToFrac l)++setColorFromWand :: (MonadResource m) => PPixelWand -> PPixelWand -> m ()+setColorFromWand = (liftIO .). F.pixelSetColorFromWand++getIndex :: (MonadResource m) => PPixelWand -> m IndexPacket+getIndex = liftIO . ((fmap fromIntegral) . F.pixelGetIndex)++setIndex :: (MonadResource m) => PPixelWand -> IndexPacket -> m ()+setIndex w i = liftIO $ F.pixelSetIndex w (fromIntegral i)++getQuantumColor :: (MonadResource m) => PPixelWand -> m PPixelPacket+getQuantumColor w = liftIO $ do+ p <- mallocForeignPtr+ withForeignPtr p (F.pixelGetQuantumColor w)+ return p++setQuantumColor :: (MonadResource m) => PPixelWand -> PPixelPacket -> m ()+setQuantumColor w p = liftIO $ withForeignPtr p (F.pixelSetQuantumColor w)++getFuzz :: (MonadResource m) => PPixelWand -> m Double+getFuzz = liftIO . ((fmap realToFrac) . F.pixelGetFuzz)++setFuzz :: (MonadResource m) => PPixelWand -> Double -> m ()+setFuzz w i = liftIO $ F.pixelSetFuzz w (realToFrac i)++isPixelWandSimilar :: (MonadResource m) => PPixelWand -> PPixelWand -> Double -> m Bool+isPixelWandSimilar pw1 pw2 fuzz = fromMBool $ F.isPixelWandSimilar pw1 pw2 (realToFrac fuzz)++setRedQuantum :: (MonadResource m) => PPixelWand -> Quantum -> m ()+setRedQuantum = (liftIO .) . F.pixelSetRedQuantum++getRed :: (MonadResource m) => PPixelWand -> m Double+getRed = (fmap realToFrac) . liftIO . F.pixelGetRed++setRed :: (MonadResource m) => PPixelWand -> Double -> m ()+setRed = (liftIO .) . (. realToFrac) . F.pixelSetRed++getRedQuantum :: (MonadResource m) => PPixelWand -> m Quantum+getRedQuantum = liftIO . F.pixelGetRedQuantum++setGreenQuantum :: (MonadResource m) => PPixelWand -> Quantum -> m ()+setGreenQuantum = (liftIO .) . F.pixelSetGreenQuantum++getGreen :: (MonadResource m) => PPixelWand -> m Double+getGreen = (fmap realToFrac) . liftIO . F.pixelGetGreen++setGreen :: (MonadResource m) => PPixelWand -> Double -> m ()+setGreen = (liftIO .) . (. realToFrac) . F.pixelSetGreen++getGreenQuantum :: (MonadResource m) => PPixelWand -> m Quantum+getGreenQuantum = liftIO . F.pixelGetGreenQuantum++setBlueQuantum :: (MonadResource m) => PPixelWand -> Quantum -> m ()+setBlueQuantum = (liftIO .) . F.pixelSetBlueQuantum++getBlue :: (MonadResource m) => PPixelWand -> m Double+getBlue = (fmap realToFrac) . liftIO . F.pixelGetBlue++setBlue :: (MonadResource m) => PPixelWand -> Double -> m ()+setBlue = (liftIO .) . (. realToFrac) . F.pixelSetBlue++getBlueQuantum :: (MonadResource m) => PPixelWand -> m Quantum+getBlueQuantum = liftIO . F.pixelGetBlueQuantum++setAlphaQuantum :: (MonadResource m) => PPixelWand -> Quantum -> m ()+setAlphaQuantum = (liftIO .) . F.pixelSetAlphaQuantum++getAlphaQuantum :: (MonadResource m) => PPixelWand -> m Quantum+getAlphaQuantum = liftIO . F.pixelGetAlphaQuantum++setAlpha :: (MonadResource m) => PPixelWand -> Double -> m ()+setAlpha = (liftIO .) . (. realToFrac) . F.pixelSetAlpha++getAlpha :: (MonadResource m) => PPixelWand -> m Double+getAlpha = (fmap realToFrac) . liftIO . F.pixelGetAlpha++setOpacityQuantum :: (MonadResource m) => PPixelWand -> Quantum -> m ()+setOpacityQuantum = (liftIO .) . F.pixelSetOpacityQuantum++getOpacityQuantum :: (MonadResource m) => PPixelWand -> m Quantum+getOpacityQuantum = liftIO . F.pixelGetOpacityQuantum++setOpacity :: (MonadResource m) => PPixelWand -> Double -> m ()+setOpacity = (liftIO .) . (. realToFrac) . F.pixelSetOpacity++getOpacity :: (MonadResource m) => PPixelWand -> m Double+getOpacity = (fmap realToFrac) . liftIO . F.pixelGetOpacity++setBlackQuantum :: (MonadResource m) => PPixelWand -> Quantum -> m ()+setBlackQuantum = (liftIO .) . F.pixelSetBlackQuantum++getBlackQuantum :: (MonadResource m) => PPixelWand -> m Quantum+getBlackQuantum = liftIO . F.pixelGetBlackQuantum++setBlack :: (MonadResource m) => PPixelWand -> Double -> m ()+setBlack = (liftIO .) . (. realToFrac) . F.pixelSetBlack++getBlack :: (MonadResource m) => PPixelWand -> m Double+getBlack = (fmap realToFrac) . liftIO . F.pixelGetBlack++setCyanQuantum :: (MonadResource m) => PPixelWand -> Quantum -> m ()+setCyanQuantum = (liftIO .) . F.pixelSetCyanQuantum++getCyanQuantum :: (MonadResource m) => PPixelWand -> m Quantum+getCyanQuantum = liftIO . F.pixelGetCyanQuantum++setCyan :: (MonadResource m) => PPixelWand -> Double -> m ()+setCyan = (liftIO .) . (. realToFrac) . F.pixelSetCyan++getCyan :: (MonadResource m) => PPixelWand -> m Double+getCyan = (fmap realToFrac) . liftIO . F.pixelGetCyan++setMagentaQuantum :: (MonadResource m) => PPixelWand -> Quantum -> m ()+setMagentaQuantum = (liftIO .) . F.pixelSetMagentaQuantum++getMagentaQuantum :: (MonadResource m) => PPixelWand -> m Quantum+getMagentaQuantum = liftIO . F.pixelGetMagentaQuantum++setMagenta :: (MonadResource m) => PPixelWand -> Double -> m ()+setMagenta = (liftIO .) . (. realToFrac) . F.pixelSetMagenta++getMagenta :: (MonadResource m) => PPixelWand -> m Double+getMagenta = (fmap realToFrac) . liftIO . F.pixelGetMagenta++setYellowQuantum :: (MonadResource m) => PPixelWand -> Quantum -> m ()+setYellowQuantum = (liftIO .) . F.pixelSetYellowQuantum++getYellowQuantum :: (MonadResource m) => PPixelWand -> m Quantum+getYellowQuantum = liftIO . F.pixelGetYellowQuantum++setYellow :: (MonadResource m) => PPixelWand -> Double -> m ()+setYellow = (liftIO .) . (. realToFrac) . F.pixelSetYellow++getYellow :: (MonadResource m) => PPixelWand -> m Double+getYellow = (fmap realToFrac) . liftIO . F.pixelGetYellow++---+with3 f = alloca (\x -> alloca (\y -> alloca (\z -> do+ f x y z+ x' <- peek x+ y' <- peek y+ z' <- peek z+ return (x',y',z')+ )))+map3 f (a,b,c) = (f a, f b, f c)
+ Graphics/ImageMagick/MagickWand/Types.hs view
@@ -0,0 +1,81 @@+{-# OPTIONS -fno-warn-orphans #-}+{-# LANGUAGE DeriveDataTypeable #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE RankNTypes #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeFamilies #-}+module Graphics.ImageMagick.MagickWand.Types+ ( PPixelIterator+ , PPixelWand+ , PPixelPacket+ , PMagickPixelPacket+ , PDrawingWand+ , PMagickWand+ , MagickWandException(..)+ -- * support for ImageMagick Exceptions+ , ExceptionCarrier(..)+ , module Graphics.ImageMagick.MagickCore.Types+ , Pixel(..)+ ) where++import qualified Data.Vector.Storable as V+import Foreign+import Foreign.C.String+import Graphics.ImageMagick.MagickCore.Exception+import Graphics.ImageMagick.MagickCore.Types+import Graphics.ImageMagick.MagickWand.FFI.DrawingWand as F+import Graphics.ImageMagick.MagickWand.FFI.MagickWand as F+import Graphics.ImageMagick.MagickWand.FFI.PixelIterator as F+import Graphics.ImageMagick.MagickWand.FFI.PixelWand as F+import Graphics.ImageMagick.MagickWand.FFI.Types++type PPixelIterator = Ptr PixelIterator+type PPixelWand = Ptr PixelWand+type PMagickWand = Ptr MagickWand+type PDrawingWand = Ptr DrawingWand+type PMagickPixelPacket = ForeignPtr MagickPixelPacket+type PPixelPacket = ForeignPtr PixelPacket++constructException :: forall t.+ (t -> Ptr ExceptionType -> IO CString)+ -> t -> IO MagickWandException+constructException f w = alloca $ \x -> do+ s <- peekCString =<< f w x+ x' <- peek x+ return $ MagickWandException (toSeverity x') x' s+{-# INLINE constructException #-}++instance ExceptionCarrier (Ptr MagickWand) where+ getException = constructException F.magickGetException++instance ExceptionCarrier (Ptr PixelIterator) where+ getException = constructException F.pixelGetIteratorException++instance ExceptionCarrier (Ptr PixelWand) where+ getException = constructException F.pixelGetException++instance ExceptionCarrier (Ptr DrawingWand) where+ getException = constructException F.drawGetException++class (Storable a) => Pixel a where+ pixelStorageType :: [a] -> StorageType+ withPixels :: [a] -> (Ptr a -> IO b) -> IO b+ withPixels xs f = V.unsafeWith (V.fromList xs) f++instance Pixel Word8 where+ pixelStorageType = const charPixel++instance Pixel Word16 where+ pixelStorageType = const shortPixel++instance Pixel Word32 where+ pixelStorageType = const longPixel++instance Pixel Word64 where+ pixelStorageType = const longPixel++instance Pixel Float where+ pixelStorageType = const floatPixel++instance Pixel Double where+ pixelStorageType = const doublePixel
+ Graphics/ImageMagick/MagickWand/Utils.hs view
@@ -0,0 +1,41 @@+module Graphics.ImageMagick.MagickWand.Utils+ ( fromMBool+ , toMBool+ , withException+ , withException_+ , withExceptionIO+ )+ where++import Control.Exception.Base+import Control.Monad+import Control.Monad.IO.Class+import Control.Monad.Trans.Resource+import Graphics.ImageMagick.MagickWand.FFI.Types+import Graphics.ImageMagick.MagickWand.Types++fromMBool :: (MonadResource m) => IO MagickBooleanType -> m Bool+fromMBool = liftM (==mTrue) . liftIO+{-# INLINE fromMBool #-}++withException :: (MonadResource m, ExceptionCarrier a) => a -> IO (MagickBooleanType, b) -> m b+withException a f = liftIO $ do+ (r,b) <- f+ unless (r==mTrue) $ getException a >>= throw+ return b+{-# INLINE withException #-}++withException_ :: (MonadResource m, ExceptionCarrier a) => a -> IO MagickBooleanType -> m ()+withException_ a f = liftIO $ f >>= \x -> void $ unless (x==mTrue) (getException a >>= throw)++-- TODO find some better way around IO + MonadResource+withExceptionIO :: (ExceptionCarrier a) => a -> IO (MagickBooleanType, b) -> IO b+withExceptionIO a f = liftIO $ do+ (r,b) <- f+ unless (r==mTrue) $ getException a >>= throw+ return b++toMBool :: Bool -> MagickBooleanType+toMBool True = mTrue+toMBool False = mFalse+{-# INLINE toMBool #-}
+ Graphics/ImageMagick/MagickWand/WandImage.hs view
@@ -0,0 +1,906 @@+{-# LANGUAGE ScopedTypeVariables #-}+module Graphics.ImageMagick.MagickWand.WandImage+ ( getImageHeight+ , getImageWidth+ , getImagePixelColor+ , resizeImage+ , getImageCompressionQuality+ , setImageCompression+ , setImageCompressionQuality+ , getImageBackgroundColor+ , setImageBackgroundColor+ , extentImage+ , floodfillPaintImage+ , negateImage+ , negateImageChannel+ , getImageClipMask+ , setImageClipMask+ , compositeImage+ , compositeImageChannel+ , transparentPaintImage+ , newImage+ , drawImage+ , borderImage+ , shaveImage+ , setImageAlphaChannel+ , flipImage+ , flopImage+ , blurImage+ , blurImageChannel+ , normalizeImage+ , normalizeImageChannel+ , shadowImage+ , addImage+ , appendImages+ , addNoiseImage+ , writeImage+ , writeImages+ , setVirtualPixelMethod+ , trimImage+ , resetImagePage+ , distortImage+ , shadeImage+ , colorizeImage+ , fxImage+ , fxImageChannel+ , sigmoidalContrastImage+ , sigmoidalContrastImageChannel+ , evaluateImage+ , evaluateImageChannel+ , evaluateImages+ , rollImage+ , annotateImage+ , mergeImageLayers+ , tintImage+ , gaussianBlurImageChannel+ , gaussianBlurImage+ , setImageMatte+ , cropImage+ , shearImage+ , scaleImage+ , sparseColorImage+ , functionImage+ , functionImageChannel+ , coalesceImages+ , getNumberImages+ , getImage+ , compareImageLayers+-- , getImageFromMagickWand+-- , adaptiveBlurImage+-- , adaptiveResizeImage+-- , adaptiveSharpenImage+-- , adaptiveThresholdImage+-- , addImage+-- , addNoiseImage+-- , affineTransformImage+-- , annotateImage+-- , animateImages+-- , appendImages+-- , autoGammaImage+-- , autoLevelImage+-- , blackThresholdImage+-- , blueShiftImage+-- , blurImage+-- , borderImage+-- , brightnessContrastImage+-- , charcoalImage+-- , chopImage+-- , clampImage+-- , clipImage+-- , clipImagePath+-- , clutImage+-- , coalesceImages+-- , colorDecisionListImage+-- , colorizeImage+-- , colorMatrixImage+-- , combineImages+-- , commentImage+-- , compareImageChannels+-- , compareImageLayers+-- , compareImages+-- , compositeImage+-- , compositeLayers+-- , contrastImage+-- , contrastStretchImage+-- , convolveImage+-- , cropImage+-- , cycleColormapImage+-- , constituteImage+-- , decipherImage+-- , deconstructImages+-- , deskewImage+-- , despeckleImage+-- , destroyImage+-- , displayImage+-- , displayImages+-- , distortImage+-- , drawImage+-- , edgeImage+-- , embossImage+-- , encipherImage+-- , enhanceImage+-- , equalizeImage+-- , evaluateImage+-- , exportImagePixels+-- , extentImage+-- , filterImage+-- , flipImage+-- , floodfillPaintImage+-- , flopImage+-- , forwardFourierTransformImage+-- , frameImage+-- , functionImage+-- , fxImage+-- , gammaImage+-- , gaussianBlurImage+-- , getImage+ , getImageAlphaChannel+-- , getImageClipMask+-- , getImageBackgroundColor+ , getImageBlob+-- , getImageBluePrimary+-- , getImageBorderColor+-- , getImageChannelDepth+-- , getImageChannelDistortion+-- , getImageChannelDistortions+-- , getImageChannelFeatures+-- , getImageChannelKurtosis+-- , getImageChannelMean+-- , getImageChannelRange+-- , getImageChannelStatistics+-- , getImageColormapColor+-- , getImageColors+-- , getImageColorspace+-- , getImageCompose+-- , getImageCompression+-- , getImageCompressionQuality+ , getImageDelay+ , getImageDepth+-- , getImageDistortion+-- , getImageDispose+-- , getImageEndian+-- , getImageFilename+ , getImageFormat+-- , getImageFuzz+-- , getImageGamma+-- , getImageGravity+-- , getImageGreenPrimary+-- , getImageHeight+-- , getImageHistogram+-- , getImageInterlaceScheme+-- , getImageInterpolateMethod+-- , getImageIterations+-- , getImageLength+-- , getImageMatteColor+-- , getImageOrientation+-- , getImagePage+-- , getImagePixelColor+-- , getImageRedPrimary+-- , getImageRegion+-- , getImageRenderingIntent+ , getImageSignature+-- , getImageTicksPerSecond+-- , getImageType+-- , getImageUnits+-- , getImageVirtualPixelMethod+-- , getImageWhitePoint+-- , getImageWidth+-- , getNumberImages+-- , getImageTotalInkDensity+-- , haldClutImage+-- , hasNextImage+-- , hasPreviousImage+-- , identifyImage+-- , implodeImage+-- , importImagePixels+-- , inverseFourierTransformImage+-- , labelImage+-- , levelImage+-- , linearStretchImage+-- , liquidRescaleImage+-- , magnifyImage+-- , mergeImageLayers+-- , minifyImage+-- , modulateImage+-- , montageImage+-- , morphImages+-- , morphologyImage+-- , motionBlurImage+-- , negateImage+-- , newImage+-- , nextImage+-- , normalizeImage+-- , oilPaintImage+-- , opaquePaintImage+-- , optimizeImageLayers+-- , optimizeImageTransparency+-- , orderedPosterizeImage+-- , pingImage+-- , pingImageBlob+-- , pingImageFile+-- , polaroidImage+-- , posterizeImage+-- , previewImages+-- , previousImage+-- , quantizeImage+-- , quantizeImages+-- , radialBlurImage+-- , raiseImage+-- , randomThresholdImage+ , readImage+ , readImageBlob+-- , readImageFile+-- , remapImage+-- , resampleImage+-- , resetImagePage+-- , resizeImage+-- , rollImage+-- , rotateImage+-- , sampleImage+-- , scaleImage+-- , segmentImage+-- , selectiveBlurImage+-- , separateImageChannel+-- , sepiaToneImage+-- , setImage+-- , setImageAlphaChannel+-- , setImageBackgroundColor+-- , setImageBias+-- , setImageBluePrimary+-- , setImageBorderColor+-- , setImageChannelDepth+-- , setImageClipMask+-- , setImageColor+-- , setImageColormapColor+-- , setImageColorspace+-- , setImageCompose+-- , setImageCompression+-- , setImageCompressionQuality+ , setImageDelay+ , setImageDepth+-- , setImageDispose+-- , setImageEndian+-- , setImageExtent+-- , setImageFilename+ , setImageFormat+-- , setImageFuzz+-- , setImageGamma+-- , setImageGravity+-- , setImageGreenPrimary+-- , setImageInterlaceScheme+-- , setImageInterpolateMethod+-- , setImageIterations+-- , setImageMatte+-- , setImageMatteColor+-- , setImageOpacity+-- , setImageOrientation+-- , setImagePage+-- , setImageProgressMonitor+-- , setImageRedPrimary+-- , setImageRenderingIntent+-- , setImageScene+-- , setImageTicksPerSecond+ , setImageType+-- , setImageUnits+-- , setImageVirtualPixelMethod+-- , setImageWhitePoint+-- , shadeImage+-- , shadowImage+-- , sharpenImage+-- , shaveImage+-- , shearImage+-- , sigmoidalContrastImage+-- , similarityImage+-- , sketchImage+-- , smushImages+-- , solarizeImage+-- , sparseColorImage+-- , spliceImage+-- , spreadImage+-- , statisticImage+-- , steganoImage+-- , stereoImage+ , stripImage+-- , swirlImage+-- , textureImage+-- , thresholdImage+-- , thumbnailImage+-- , tintImage+-- , transformImage+-- , transformImageColorspace+-- , transparentPaintImage+-- , transposeImage+-- , transverseImage+-- , trimImage+-- , uniqueImageColors+-- , unsharpMaskImage+-- , vignetteImage+-- , waveImage+-- , whiteThresholdImage+-- , writeImage+-- , writeImageFile+-- , writeImages+-- , writeImagesFile+ , getImageScene+ , setImage+ , removeImage+ , importImagePixels+ , exportImagePixels+ , rotateImage+ ) where++import Control.Applicative ((<$>))+import Control.Monad.IO.Class+import Control.Monad.Trans.Resource+import Data.ByteString (ByteString,+ packCString,+ packCStringLen,+ useAsCString,+ useAsCStringLen)+import Data.Text (Text)+import qualified Data.Text as T+import Data.Text.Encoding (decodeUtf8,+ encodeUtf8)+import Data.Vector.Storable (Vector)+import qualified Data.Vector.Storable as V+import Filesystem.Path.CurrentOS+import Foreign+import Foreign.C.Types+import Graphics.ImageMagick.MagickCore.Types+import qualified Graphics.ImageMagick.MagickWand.FFI.MagickWand as F+import Graphics.ImageMagick.MagickWand.FFI.Types+import qualified Graphics.ImageMagick.MagickWand.FFI.WandImage as F+import Graphics.ImageMagick.MagickWand.MagickWand+import Graphics.ImageMagick.MagickWand.PixelWand+import Graphics.ImageMagick.MagickWand.Types+import Graphics.ImageMagick.MagickWand.Utils+import Prelude hiding+ (FilePath)++getImageHeight :: (MonadResource m) => Ptr MagickWand -> m Int+getImageHeight w = liftIO $ fmap fromIntegral (F.magickGetImageHeight w)++getImageWidth :: (MonadResource m) => Ptr MagickWand -> m Int+getImageWidth w = liftIO $ fmap fromIntegral (F.magickGetImageWidth w)++-- | returns the color of the specified pixel into the pixelwand.+getImagePixelColor :: (MonadResource m)+ => PMagickWand+ -> Int -- ^ pixel x coordinate+ -> Int -- ^ pixel y coordinate+ -> PPixelWand -- ^ return the colormap color in this wand+ -> m ()+getImagePixelColor w x y pw = withException_ w $! F.magickGetImagePixelColor w (fromIntegral x) (fromIntegral y) pw++resizeImage :: (MonadResource m) => Ptr MagickWand -> Int -> Int -> FilterTypes -> Double -> m ()+resizeImage pw w h f s = withException_ pw $! F.magickResizeImage pw (fromIntegral w) (fromIntegral h) f (realToFrac s)++getImageCompressionQuality :: (MonadResource m) => Ptr MagickWand -> m Int+getImageCompressionQuality = liftIO . fmap fromIntegral . F.magickGetImageCompressionQuality++setImageCompressionQuality :: (MonadResource m) => Ptr MagickWand -> Int -> m ()+setImageCompressionQuality w s = withException_ w $! F.magickSetImageCompressionQuality w (fromIntegral s)++getImageBackgroundColor :: (MonadResource m) => PMagickWand -> m PPixelWand+getImageBackgroundColor w = pixelWand >>= \p -> getImageBackgroundColor1 w p >> return p++getImageBackgroundColor1 :: (MonadResource m) => PMagickWand -> PPixelWand -> m ()+getImageBackgroundColor1 w p = withException_ w $! F.magickGetImageBackgroundColor w p++setImageBackgroundColor :: (MonadResource m) => PMagickWand -> PPixelWand -> m ()+setImageBackgroundColor w p = withException_ w $! F.magickSetImageBackgroundColor w p++extentImage :: (MonadResource m) => PMagickWand -> Int -> Int -> Int -> Int -> m ()+extentImage w width height offsetX offsetY = withException_ w $!+ F.magickExtentImage w (fromIntegral width) (fromIntegral height) (fromIntegral offsetX) (fromIntegral offsetY)++floodfillPaintImage :: (MonadResource m) => PMagickWand -> ChannelType -> PPixelWand -> Double -> PPixelWand -> Int -> Int -> Bool -> m ()+floodfillPaintImage w channel fill fuzz border x y invert = withException_ w $!+ F.magickFloodfillPaintImage w channel fill (realToFrac fuzz) border (fromIntegral x) (fromIntegral y) (toMBool invert)++negateImage :: (MonadResource m) => PMagickWand -> Bool -> m ()+negateImage p b = withException_ p $! F.magickNegateImage p (toMBool b)++negateImageChannel :: (MonadResource m) => PMagickWand -> ChannelType -> Bool -> m ()+negateImageChannel p c b = withException_ p $! F.magickNegateImageChannel p c (toMBool b)++getImageClipMask :: (MonadResource m) => PMagickWand -> m PMagickWand+getImageClipMask = liftIO . F.magickGetImageClipMask++setImageClipMask :: (MonadResource m) => PMagickWand -> PMagickWand -> m ()+setImageClipMask w s = withException_ w $ F.magickSetImageClipMask w s++compositeImage :: (MonadResource m) => PMagickWand -> PMagickWand -> CompositeOperator -> Int -> Int -> m ()+compositeImage p s c w h = withException_ p $ F.magickCompositeImage p s c (fromIntegral w) (fromIntegral h)++compositeImageChannel :: (MonadResource m) => PMagickWand -> PMagickWand -> ChannelType -> CompositeOperator -> Int -> Int -> m ()+compositeImageChannel p s ch c w h = withException_ p $+ F.magickCompositeImageChannel p s ch c (fromIntegral w) (fromIntegral h)++-- | transparentPaintImage changes any pixel that matches color with the color defined by fill.+transparentPaintImage :: (MonadResource m)+ => PMagickWand+ -> PPixelWand -- ^ change this color to specified opacity value withing the image+ -> Double -- ^ the level of transarency: 1.0 fully opaque 0.0 fully transparent+ -> Double -- ^ By default target must match a particular pixel color exactly.+ -- However, in many cases two colors may differ by a small amount.+ -- The fuzz member of image defines how much tolerance is acceptable+ -- to consider two colors as the same. For example, set fuzz to 10 and+ -- the color red at intensities of 100 and 102 respectively are now+ -- interpreted as the same color for the purposes of the floodfill.+ -> Bool -- paint any pixel that does not match the target color.+ -> m ()+transparentPaintImage w p alfa fuzz invert = withException_ w $ F.magickTransparentPaintImage w p alfa fuzz (toMBool invert)++-- | newImage adds a blank image canvas of the specified size and background color to the wand.+newImage :: (MonadResource m)+ => PMagickWand+ -> Int -- ^ width+ -> Int -- ^ height+ -> PPixelWand -- ^ background color+ -> m ()+newImage p width height b = withException_ p $! F.magickNewImage p (fromIntegral width) (fromIntegral height) b++-- | drawImage renders the drawing wand on the current image.+drawImage :: (MonadResource m) => PMagickWand -> PDrawingWand -> m ()+drawImage p d = withException_ p $ F.magickDrawImage p d++borderImage :: (MonadResource m) => PMagickWand -> PPixelWand -> Int -> Int -> m ()+borderImage w bordercolor height width = withException_ w $ F.magickBorderImage w bordercolor (fromIntegral width) (fromIntegral height)++shaveImage :: (MonadResource m) => PMagickWand -> Int -> Int -> m ()+shaveImage w columns rows = withException_ w $ F.magickShaveImage w (fromIntegral columns) (fromIntegral rows)++setImageAlphaChannel :: (MonadResource m) => PMagickWand -> AlphaChannelType -> m ()+setImageAlphaChannel w alpha_type = withException_ w $ F.magickSetImageAlphaChannel w alpha_type++flipImage :: (MonadResource m) => Ptr MagickWand -> m ()+flipImage w = withException_ w $ F.magickFlipImage w++flopImage :: (MonadResource m) => Ptr MagickWand -> m ()+flopImage w = withException_ w $ F.magickFlopImage w++addImage :: (MonadResource m) => PMagickWand -> PMagickWand -> m ()+addImage w w' = withException_ w $ F.magickAddImage w w'++-- | MagickAppendImages() append the images in a wand from the current image onwards,+-- creating a new wand with the single image result. This is affected by the gravity+-- and background settings of the first image.+-- Typically you would call either MagickResetIterator() or MagickSetFirstImage() before+-- calling this function to ensure that all the images in the wand's image list will be appended together.+appendImages :: (MonadResource m)+ => PMagickWand+ -> Bool -- ^ By default, images are stacked left-to-right. Set stack to MagickTrue to stack them top-to-bottom.+ -> m (ReleaseKey, PMagickWand)+appendImages w b = allocate (F.magickAppendImages w (toMBool b)) (void . F.destroyMagickWand)++-- | MagickAddNoiseImage() adds random noise to the image.+--+addNoiseImage :: (MonadResource m)+ => PMagickWand+ -> NoiseType -- ^ The type of noise: Uniform, Gaussian, Multiplicative, Impulse, Laplacian, or Poisson.+ -> m ()+addNoiseImage w n = withException_ w $ F.magickAddNoiseImage w n++-- | writeImage() writes an image to the specified filename. If the filename+-- parameter is Nothing, the image is written to the filename set by MagickReadImage+-- or MagickSetImageFilename().+writeImage :: (MonadResource m)+ => PMagickWand+ -> 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)++writeImages :: (MonadResource m) => Ptr MagickWand -> FilePath -> Bool -> m ()+writeImages w fn b = withException_ w $ useAsCString (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+-- results, the radius should be larger than sigma. Use a radius of 0 and+-- BlurImage() selects a suitable radius for you.+--+-- The format of the MagickBlurImage method is:+blurImage :: (MonadResource m) => PMagickWand -> Double -> Double -> m ()+blurImage w r s = withException_ w $ F.magickBlurImage w (realToFrac r) (realToFrac s)++blurImageChannel :: (MonadResource m) => PMagickWand -> ChannelType -> Double -> Double -> m ()+blurImageChannel w c r s = withException_ w $ F.magickBlurImageChannel w c (realToFrac r) (realToFrac s)++-- | MagickNormalizeImage() enhances the contrast of a color image by adjusting+-- the pixels color to span the entire range of colors available+--+-- You can also reduce the influence of a particular channel with a gamma+-- value of 0.+normalizeImage :: (MonadResource m) => PMagickWand -> m ()+normalizeImage w = withException_ w $ F.magickNormalizeImage w++normalizeImageChannel :: (MonadResource m) => PMagickWand -> ChannelType -> m ()+normalizeImageChannel w c = withException_ w $ F.magickNormalizeImageChannel w c++-- | Simulates an image shadow.+shadowImage :: (MonadResource m)+ => PMagickWand -- ^ the magick wand+ -> Double -- ^ percentage transparency+ -> Double -- ^ the standard deviation of the Gaussian, in pixels+ -> Int -- ^ the shadow x-offset+ -> Int -- ^ the shadow y-offset+ -> m ()+shadowImage w opacity sigma x y = withException_ w $ F.magickShadowImage w (realToFrac opacity) (realToFrac sigma)+ (fromIntegral x) (fromIntegral y)++-- | sets the image virtual pixel method.+-- the image virtual pixel method : UndefinedVirtualPixelMethod, ConstantVirtualPixelMethod,+-- EdgeVirtualPixelMethod, MirrorVirtualPixelMethod, or TileVirtualPixelMethod.+setVirtualPixelMethod :: (MonadResource m) => PMagickWand -> VirtualPixelMethod -> m VirtualPixelMethod+setVirtualPixelMethod = (liftIO .). F.magickSetVirtualPixelMethod++-- | Remove edges that are the background color from the image.+trimImage :: (MonadResource m) => PMagickWand -> Double -> m ()+trimImage w fuzz = withException_ w $ F.magickTrimImage w (realToFrac fuzz)++-- | Resets the Wand page canvas and position.+resetImagePage :: (MonadResource m) => PMagickWand -> Maybe Text -> m ()+resetImagePage w Nothing = withException_ w $ F.magickResetImagePage w nullPtr+resetImagePage w (Just page) = withException_ w $ useAsCString (encodeUtf8 page) (F.magickResetImagePage w)++-- | Resets the Wand page canvas and position.+distortImage :: (MonadResource m)+ => PMagickWand+ -> DistortImageMethod -- ^ the method of image distortion+ -> [Double] -- ^ the arguments for this distortion method+ -> Bool -- ^ attempt to resize destination to fit distorted source+ -> m ()+distortImage w method args bestfit = withException_ w $! withArrayLen (map realToFrac args) distort+ where+ distort len arr = F.magickDistortImage w method (fromIntegral len) arr (toMBool bestfit)++-- | Sshines a distant light on an image to create+-- a three-dimensional effect. You control the positioning of the light+-- with azimuth and elevation; azimuth is measured in degrees off the x axis+-- and elevation is measured in pixels above the Z axis.+shadeImage :: (MonadResource m)+ => PMagickWand+ -> Bool -- ^ a value other than zero shades the intensity of each pixel+ -> Double -- ^ azimuth of the light source direction+ -> Double -- ^ evelation of the light source direction+ -> m ()+shadeImage w gray azimuth elevation = withException_ w $ F.magickShadeImage w (toMBool gray)+ (realToFrac azimuth) (realToFrac elevation)++-- | Resets the Wand page canvas and position.+colorizeImage :: (MonadResource m) => PMagickWand -> PPixelWand -> PPixelWand -> m ()+colorizeImage w colorize opacity = withException_ w $! F.magickColorizeImage w colorize opacity++-- | Evaluate expression for each pixel in the image.+fxImage :: (MonadResource m) => PMagickWand -> Text -> m (ReleaseKey, Ptr MagickWand)+fxImage w expr = wandResource (useAsCString (encodeUtf8 expr) (F.magickFxImage w))++-- | Evaluate expression for each pixel in the image.+fxImageChannel :: (MonadResource m) => PMagickWand -> ChannelType -> Text -> m (ReleaseKey, Ptr MagickWand)+fxImageChannel w channel expr = wandResource (useAsCString (encodeUtf8 expr) (F.magickFxImageChannel w channel))++-- | Adjusts the contrast of an image with a non-linear sigmoidal contrast algorithm.+-- Increase the contrast of the image using a sigmoidal transfer function without+-- saturating highlights or shadows. Contrast indicates how much to increase the contrast+-- (0 is none; 3 is typical; 20 is pushing it); mid-point indicates where midtones fall+-- in the resultant image (0 is white; 50 is middle-gray; 100 is black). Set sharpen to `True`+-- to increase the image contrast otherwise the contrast is reduced.+sigmoidalContrastImage :: (MonadResource m) => PMagickWand -> Bool -> Double -> Double -> m ()+sigmoidalContrastImage w sharpen alpha beta =+ withException_ w $! F.magickSigmoidalContrastImage w (toMBool sharpen) (realToFrac alpha) (realToFrac beta)++-- see `sigmoidalContrastImage`+sigmoidalContrastImageChannel :: (MonadResource m) => PMagickWand -> ChannelType -> Bool -> Double -> Double -> m ()+sigmoidalContrastImageChannel w channel sharpen alpha beta =+ withException_ w $! F.magickSigmoidalContrastImageChannel w channel (toMBool sharpen) (realToFrac alpha) (realToFrac beta)++-- | Applies an arithmetic, relational, or logical expression to an image.+-- Use these operators to lighten or darken an image, to increase or decrease+-- contrast in an image, or to produce the "negative" of an image.+evaluateImage :: (MonadResource m)+ => PMagickWand+ -> MagickEvaluateOperator -- ^ a channel operator+ -> CDouble -- ^ value+ -> m ()+evaluateImage w op value = withException_ w $! F.magickEvaluateImage w op value++-- | see `evaluateImage`+evaluateImages :: (MonadResource m)+ => PMagickWand+ -> MagickEvaluateOperator -- ^ a channel operator+ -> m ()+evaluateImages w op = withException_ w $! F.magickEvaluateImages w op++-- | see `evaluateImage`+evaluateImageChannel :: (MonadResource m)+ => PMagickWand+ -> ChannelType -- ^ the channel(s)+ -> MagickEvaluateOperator -- ^ a channel operator+ -> CDouble -- ^ value+ -> m ()+evaluateImageChannel w channel op value = withException_ w $! F.magickEvaluateImageChannel w channel op value++-- | Offsets an image as defined by x and y.+rollImage :: (MonadResource m) => PMagickWand -> Double -> Double -> m ()+rollImage w x y = withException_ w $! F.magickRollImage w (realToFrac x) (realToFrac y)++-- | Annotates an image with text.+annotateImage :: (MonadResource m)+ => PMagickWand+ -> PDrawingWand -- ^ the draw wand+ -> Double -- ^ x ordinate to left of text+ -> Double -- ^ y ordinate to text baseline+ -> Double -- ^ rotate text relative to this angle+ -> Text -- ^ text to draw+ -> m ()+annotateImage w dw x y angle text =+ withException_ w $! useAsCString (encodeUtf8 text)+ (F.magickAnnotateImage w dw (realToFrac x) (realToFrac y) (realToFrac angle))++-- | Composes all the image layers from the current given image onward to+-- produce a single image of the merged layers. The inital canvas's size+-- depends on the given ImageLayerMethod, and is initialized using the first+-- images background color. The images are then compositied onto that image+-- in sequence using the given composition that has been assigned to each+-- individual image.+mergeImageLayers :: (MonadResource m) => PMagickWand -> ImageLayerMethod -> m (ReleaseKey, PMagickWand)+mergeImageLayers w method = wandResource (F.magickMergeImageLayers w method)++-- | Applies a color vector to each pixel in the image. The length of the+-- vector is 0 for black and white and at its maximum for the midtones.+-- The vector weighting function is f(x)=(1-(4.0*((x-0.5)*(x-0.5)))).+--+-- The format of the MagickTintImage method is:+tintImage :: (MonadResource m) => PMagickWand+ -> PPixelWand -- ^ tint pixel+ -> PPixelWand -- ^ opacity pixel+ -> m ()+tintImage w t o = withException_ w $ F.magickTintImage w t o+++-- | MagickGaussianBlurImage() blurs an image. We convolve the image with a Gaussian operator+-- of the given radius and standard deviation (sigma). For reasonable results, the radius should+-- be larger than sigma. Use a radius of 0 and MagickGaussianBlurImage() selects a suitable radius for you.+gaussianBlurImage :: (MonadResource m) => PMagickWand+ -> Double+ -> Double+ -> m ()+gaussianBlurImage w r s = withException_ w $ F.magickGaussianBlurImage w (realToFrac r) (realToFrac s)++gaussianBlurImageChannel :: (MonadResource m) => PMagickWand+ -> ChannelType+ -> Double+ -> Double+ -> m ()+gaussianBlurImageChannel w c r s = withException_ w $ F.magickGaussianBlurImageChannel w c (realToFrac r) (realToFrac s)++setImageMatte :: (MonadResource m) => PMagickWand+ -> Bool+ -> m ()+setImageMatte w b = withException_ w $ F.magickSetImageMatte w (toMBool b)++-- | Extracts a region of the image.+cropImage :: (MonadResource m) => PMagickWand+ -> Int -- ^ the region width+ -> Int -- ^ the region height+ -> Int -- ^ the region x-offset+ -> Int -- ^ the region y-offset+ -> m ()+cropImage w width height x y = withException_ w $ F.magickCropImage w (fromIntegral width) (fromIntegral height)+ (fromIntegral x) (fromIntegral y)++-- | Slides one edge of an image along the X or Y axis, creating+-- a parallelogram. An X direction shear slides an edge along+-- the X axis, while a Y direction shear slides an edge along+-- the Y axis. The amount of the shear is controlled by a shear+-- angle. For X direction shears, x_shear is measured relative+-- to the Y axis, and similarly, for Y direction shears y_shear is+-- measured relative to the X axis. Empty triangles left over from+-- shearing the image are filled with the background color.+shearImage :: (MonadResource m) => PMagickWand+ -> PPixelWand -- ^ the background pixel wand+ -> Double -- ^ the number of degrees to shear the image+ -> Double -- ^ the number of degrees to shear the image+ -> m ()+shearImage w pw x_shear y_shear =+ withException_ w $ F.magickShearImage w pw (realToFrac x_shear) (realToFrac y_shear)++-- | Scales the size of an image to the given dimensions.+scaleImage :: (MonadResource m) => PMagickWand+ -> Int -- ^ the number of degrees to shear the image+ -> Int -- ^ the number of degrees to shear the image+ -> m ()+scaleImage w columns rows =+ withException_ w $ F.magickScaleImage w (fromIntegral columns) (fromIntegral rows)+++-- | MagickSparseColorImage(), given a set of coordinates, interpolates the+-- colors found at those coordinates, across the whole image, using various methods.+--+-- The format of the MagickSparseColorImage method is:+-- ArcSparseColorion will always ignore source image offset, and always 'bestfit'+-- the destination image with the top left corner offset relative to the polar mapping center.+--+-- Bilinear has no simple inverse mapping so will not allow 'bestfit' style of image sparseion.+--+-- Affine, Perspective, and Bilinear, will do least squares fitting of the distrotion when more+-- than the minimum number of control point pairs are provided.+--+-- Perspective, and Bilinear, will fall back to a Affine sparseion when less than 4 control+-- point pairs are provided. While Affine sparseions will let you use any number of control+-- point pairs, that is Zero pairs is a No-Op (viewport only) distrotion, one pair is a+-- translation and two pairs of control points will do a scale-rotate-translate, without any+-- shearing.+sparseColorImage :: (MonadResource m) => PMagickWand+ -> ChannelType+ -> SparseColorMethod+ -> Vector Double+ -> m()+sparseColorImage w c m v =+ withException_ w $ V.unsafeWith v $ \v' -> F.magickSparseColorImage w c m (fromIntegral $ V.length v) v'++-- | MagickFunctionImage() applys an arithmetic, relational, or logical expression to an image.+-- Use these operators to lighten or darken an image, to increase or decrease contrast in an+-- image, or to produce the "negative" of an image.+functionImage :: (MonadResource m) => PMagickWand -> MagickFunction -> Vector Double -> m ()+functionImage w f v =+ withException_ w $ V.unsafeWith v $ \v' -> F.magickFunctionImage w f (fromIntegral $ V.length v) v'++functionImageChannel :: (MonadResource m) => PMagickWand -> ChannelType -> MagickFunction -> Vector Double -> m ()+functionImageChannel w c f v =+ withException_ w $ V.unsafeWith v $ \v' -> F.magickFunctionImageChannel w c f (fromIntegral $ V.length v) v'+++-- | MagickCoalesceImages() composites a set of images while respecting any page offsets and disposal methods. GIF, MIFF, and MNG animation sequences typically start with an image background and each subsequent image varies in size and offset. MagickCoalesceImages() returns a new sequence where each image in the sequence is the same size as the first and composited with the next image in the sequence.+coalesceImages :: (MonadResource m) => PMagickWand+ -> m (ReleaseKey, PMagickWand)+coalesceImages = wandResource . F.magickCoalesceImages++-- | returns the number of images associated with a magick wand.+getNumberImages :: (MonadResource m) => PMagickWand -> m Int+getNumberImages w = liftIO $ fromIntegral <$> F.magickGetNumberImages w++-- | Gets the image at the current image index.+getImage :: (MonadResource m) => PMagickWand -> m (ReleaseKey, PMagickWand)+getImage = wandResource . F.magickGetImage++-- | Compares each image with the next in a sequence and returns+-- the maximum bounding region of any pixel differences it discovers.+compareImageLayers :: (MonadResource m) => PMagickWand -> ImageLayerMethod -> m (ReleaseKey, PMagickWand)+compareImageLayers = (wandResource .). F.magickCompareImageLayers++-- | Gets the image scene+getImageScene :: (MonadResource m) => PMagickWand -> m Int+getImageScene w = liftIO $ fromIntegral <$> F.magickGetImageScene w++-- | MagickRemoveImage() removes an image from the image list.+removeImage :: (MonadResource m) => PMagickWand -> m ()+removeImage w = withException_ w $ F.magickRemoveImage w++-- | Replaces the last image returned by `setImageIndex` and+-- iteration methods with the images from the specified wand.+setImage :: (MonadResource m) => PMagickWand -> PMagickWand -> m ()+setImage w sw = withException_ w $ F.magickSetImage w sw++-- | Accepts pixel data. The pixel data can be in any `Pixels` format+-- in the order specified by map.+importImagePixels :: (MonadResource m, Pixel a) => PMagickWand+ -> Int -- ^ x+ -> Int -- ^ y+ -> Int -- ^ columns+ -> Int -- ^ rows+ -- TODO migrate to typesafe parameter+ -> Text -- ^ map+ -> [a] -- ^ imported pixels+ -> m ()+importImagePixels w x y width height cmap pixels =+ withException_ w $ useAsCString (encodeUtf8 cmap) $ \cstr ->+ withPixels pixels $ (F.magickImportImagePixels w x' y' width' height' cstr stype) . castPtr+ where+ x' = fromIntegral x+ y' = fromIntegral y+ width' = fromIntegral width+ height' = fromIntegral height+ stype = pixelStorageType pixels++-- | Extracts pixel data from an image and returns it to you. The data is+-- returned as `Pixels` in the order specified by cmap.+exportImagePixels :: (MonadResource m, Pixel a) => PMagickWand+ -> Int -- ^ x+ -> Int -- ^ y+ -> Int -- ^ columns+ -> Int -- ^ rows+ -- TODO migrate to typesafe parameter+ -> Text -- ^ map+ -> m [a]+exportImagePixels w x y width height cmap = liftIO $ useAsCString (encodeUtf8 cmap) $ \cstr ->+ exportArray arrLength (F.magickExportImagePixels w x' y' width' height' cstr) (undefined)+ where+ exportArray :: (Pixel a) => Int -> (StorageType -> Ptr () -> IO b) -> [a] -> IO [a]+ exportArray s f hack = allocaArray s (\q -> f storage (castPtr q) >> peekArray s q)+ where storage = pixelStorageType hack+ x' = fromIntegral x+ y' = fromIntegral y+ width' = fromIntegral width+ height' = fromIntegral height+ arrLength = width * height * (T.length cmap)++-- | Rotates an image the specified number of degrees. Empty triangles left over+-- from rotating the image are filled with the background color.+rotateImage :: (MonadResource m) => PMagickWand -> PPixelWand -> Double -> m ()+rotateImage w background degrees = withException_ w $ F.magickRotateImage w background (realToFrac degrees)++-- | Gets the image depth.+getImageDepth :: (MonadResource m) => PMagickWand -> m Int+getImageDepth w = liftIO $ fromIntegral <$> F.magickGetImageDepth w++-- | Sets the image depth.+setImageDepth :: (MonadResource m) => PMagickWand -> Int -> m ()+setImageDepth w depth = withException_ w $ F.magickSetImageDepth w (fromIntegral depth)++-- | Sets the image compression.+setImageCompression:: (MonadResource m) => PMagickWand -> CompressionType -> m ()+setImageCompression w compressionType = withException_ w $ F.magickSetImageCompression w compressionType++-- | Gets the image delay.+getImageDelay :: (MonadResource m) => PMagickWand -> m Int+getImageDelay w = liftIO $ fromIntegral <$> F.magickGetImageDelay w++-- | Sets the image delay.+setImageDelay :: (MonadResource m) => PMagickWand -> Int -> m ()+setImageDelay w delay = withException_ w $ F.magickSetImageDelay w (fromIntegral delay)++-- | MagickGetImageBlob() implements direct to memory image formats.+-- It returns the image as a blob (a formatted "file" in memory) and+-- its length, starting from the current position in the image sequence.+-- Use 'setImageFormat' to set the format to write to the blob (GIF, JPEG, PNG, etc.).+-- ImageMagick blob is automatically freed in this function, returned bytestring+-- is on haskell heap.+getImageBlob :: (MonadResource m) => PMagickWand -> m ByteString+getImageBlob w = liftIO $ do+ F.magickResetIterator w+ cl <- alloca $ \x -> do+ c <- F.magickGetImageBlob w x+ x' <- fmap fromIntegral (peek x)+ return (c,x')+ out <- packCStringLen cl+ F.magickRelinquishMemory $ castPtr $ fst cl+ return out++-- | 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)++-- | Reads an image or image sequence from a blob+readImageBlob :: (MonadResource m) => PMagickWand -> ByteString -> m ()+readImageBlob w bs = withException_ w $ useAsCStringLen bs $+ \(cstr, len) -> F.magickReadImageBlob w (castPtr cstr) (fromIntegral len)++-- | Returns the format of a particular image in a sequence.+getImageFormat :: (MonadResource m) => PMagickWand -> m Text+getImageFormat w = liftIO $ do+ cstr <- F.magickGetImageFormat w+ -- TODO: check if we need to release string memory+ decodeUtf8 <$> packCString cstr++setImageFormat :: (MonadResource m) => PMagickWand -> Text -> m ()+setImageFormat w format = withException_ w $ useAsCString (encodeUtf8 format) (F.magickSetImageFormat w)++-- | Strips an image of all profiles and comments.+stripImage :: (MonadResource m) => PMagickWand -> m ()+stripImage w = withException_ w $ (F.magickStripImage w)++-- | Generates an SHA-256 message digest for the image pixel stream+getImageSignature :: (MonadResource m) => PMagickWand -> m ByteString+getImageSignature w = liftIO $ F.magickGetImageSignature w >>= packCString++-- | Returns `False` if the image alpha channel is not activated.+-- That is, the image is RGB rather than RGBA or CMYK rather than CMYKA.+getImageAlphaChannel :: (MonadResource m) => PMagickWand -> m Bool+getImageAlphaChannel = fromMBool . F.magickGetImageAlphaChannel++-- | Sets image Type+setImageType :: (MonadResource m) => PMagickWand -> ImageType -> m ()+setImageType w imageType = withException_ w $ F.magickSetImageType w imageType
imagemagick.cabal view
@@ -1,5 +1,5 @@ Name: imagemagick-Version: 0.0.1+Version: 0.0.2 Synopsis: bindings to imagemagick library License: OtherLicense License-file: LICENSE@@ -44,8 +44,20 @@ , Graphics.ImageMagick.MagickCore.Types.FFI.AlphaChannelType , Graphics.ImageMagick.MagickCore.Types.FFI.ColorspaceType , Graphics.ImageMagick.MagickCore.Types.MBits+ , Graphics.ImageMagick.MagickCore.Types+ , Graphics.ImageMagick.MagickCore.Option+ , Graphics.ImageMagick.MagickCore.Mime , Graphics.ImageMagick.MagickCore.Exception+ , Graphics.ImageMagick.MagickCore.Gem , Graphics.ImageMagick.MagickWand+ , Graphics.ImageMagick.MagickWand.WandImage+ , Graphics.ImageMagick.MagickWand.Types+ , Graphics.ImageMagick.MagickWand.PixelWand+ , Graphics.ImageMagick.MagickWand.PixelPacket+ , Graphics.ImageMagick.MagickWand.PixelIterator+ , Graphics.ImageMagick.MagickWand.MagickWand+ , Graphics.ImageMagick.MagickWand.DrawingWand+ , Graphics.ImageMagick.MagickWand.Utils , Graphics.ImageMagick.MagickWand.FFI.ImageDrawing , Graphics.ImageMagick.MagickWand.FFI.DrawingWand , Graphics.ImageMagick.MagickWand.FFI.MagickWand