Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial layout

  • Loading branch information...
commit fb203c73d63721ae0c900983674545d6b3fa9b27 0 parents
Alexander Vershilov authored
55 Graphics/ImageMagick/MagickWand.hs
@@ -0,0 +1,55 @@
+{-# LANGUAGE PackageImports #-}
+module Graphics.ImageMagick.MagickWand where
+
+import Prelude hiding (FilePath)
+import "mtl" Control.Monad.Reader -- TODO: remove
+import Control.Exception
+import Control.Monad.IO.Class
+import Graphics.ImageMagick.MagickWand.Internal
+import Filesystem.Path.CurrentOS
+import Data.ByteString
+import Foreign
+import Foreign.C
+
+data Filter -- TODO: change name
+type PMagickWand = Ptr MagickWand
+type MagickR a = ReaderT PMagickWand IO a
+
+-- | Create magic wand environment and closes it at the
+-- end of the work, should wrap all MagickWand functions
+withMagickWandGenesis :: IO a -> IO a
+withMagickWandGenesis f = bracket start finish (const f)
+ where
+ start = magickWandGenesis
+ finish = const magickWandTerminus
+
+withMagickWand :: (MagickR a) -> IO a
+withMagickWand f = bracket start close (runReaderT f)
+ where
+ start = newMagickWand
+ close = destroyMagickWand
+
+
+magickIterate :: (MagickR a) -> (MagickR ())
+magickIterate f = ask >>= \w -> liftIO (magickResetIterator w) >> go w f -- TODO: use fix
+ where
+ go w f = do
+ i <- lift (magickNextImage w)
+ unless (i==0) $ f >> go w f
+
+resizeImage :: CInt -> CInt -> FilterTypes -> CDouble -> MagickR Bool
+resizeImage w h f s = ask >>= \m -> fmap (/=0) $! lift (magickResizeImage m w h f s)
+
+readImage :: FilePath -> MagickR Bool -- TODO: move to apropiate file
+readImage fn = do
+ w <- ask
+ r <- lift $ useAsCString (encode fn) (magickReadImage w)
+ return (r/=0)
+
+writeImages :: FilePath -> Bool -> MagickR Bool
+writeImages fn b = do
+ w <- ask
+ r <- lift $ useAsCString (encode fn) (\f -> magickWriteImages w f b')
+ return (r/=0)
+ where b' = if b then 1 else 0
+
384 Graphics/ImageMagick/MagickWand/Internal.hsc
@@ -0,0 +1,384 @@
+{-# LANGUAGE CPP, ForeignFunctionInterface #-}
+
+module Graphics.ImageMagick.MagickWand.Internal
+ where
+
+import Foreign
+import Foreign.C.Types
+import Foreign.C.String
+
+#include <wand/MagickWand.h>
+
+-- MagickWand type
+data MagickWand
+data Image
+type MagickBooleanType = CInt
+
+
+-- | MagickWandGenesis() initializes the MagickWand environment.
+foreign import ccall "wand/MagickWand.h MagickWandGenesis" magickWandGenesis
+ :: IO ()
+
+-- | MagickWandTerminus() terminates the MagickWand environment.
+foreign import ccall "wand/MagickWand.h MagickWandTerminus" magickWandTerminus
+ :: IO ()
+
+-- * Constructing magic wand
+
+-- | NewMagickWand() returns a wand required for all other methods in the API.
+-- A fatal exception is thrown if there is not enough memory to allocate the wand.
+-- Use DestroyMagickWand() to dispose of the wand when it is no longer needed.
+foreign import ccall "wand/MagickWand.h NewMagickWand" newMagickWand
+ :: IO (Ptr MagickWand)
+
+
+-- | NewMagickWandFromImage() returns a wand with an image.
+foreign import ccall "wand/MagickWand.h NewMagickWandFromImage" newMagickWandFromImage
+ :: Ptr Image -- ^ Image
+ -> IO (Ptr MagickWand)
+
+
+
+-- | CloneMagickWand() makes an exact copy of the specified wand.
+foreign import ccall "wand/MagickWand.h CloneMagickWand" cloneMagickWand
+ :: Ptr MagickWand -> IO (Ptr MagickWand)
+
+-- * Clearing and destroying
+
+-- | ClearMagickWand() clears resources associated with the wand,
+-- leaving the wand blank, and ready to be used for a new set of images.
+foreign import ccall "wand/MagickWand.h ClearMagickWand" clearMagickWand
+ :: Ptr MagickWand -> IO ()
+
+-- | DestroyMagickWand() deallocates memory associated with an MagickWand.
+foreign import ccall "wand/MagickWand.h DestroyMagickWand" destroyMagickWand
+ :: Ptr MagickWand -> IO (Ptr MagickWand)
+
+-- * Utilities
+
+-- | IsMagickWand() returns MagickTrue if the wand is verified as a magick wand.
+foreign import ccall "wand/MagickWand.h IsMagickWand" isMagicWand
+ :: Ptr MagickWand -> IO (MagickBooleanType)
+
+-- * Exceptions
+
+-- | MagickClearException() clears any exceptions associated with the wand.
+--
+foreign import ccall "wand/MagickWand.h MagickClearException" magicClearException
+ :: Ptr MagickWand -> IO (MagickBooleanType)
+
+
+-- ** Iterator
+
+-- | MagickResetIterator() resets the wand iterator.
+-- It is typically used either before iterating though images, or before calling
+-- specific functions such as MagickAppendImages() to append all images together.
+--
+-- Afterward you can use MagickNextImage() to iterate over all the images in a
+-- wand container, starting with the first image.
+--
+-- Using this before MagickAddImages() or MagickReadImages() will cause new images
+-- to be inserted between the first and second image.
+
+foreign import ccall "wand/MagickWand.h MagickResetIterator" magickResetIterator
+ :: Ptr MagickWand -> IO ()
+
+
+{-
+MagickGetException() returns the severity, reason, and description of any error that occurs when using other methods in this API.
+char *MagickGetException(const MagickWand *wand,ExceptionType *severity)
+
+MagickGetExceptionType() returns the exception type associated with the wand. If no exception has occurred, UndefinedExceptionType is returned.
+ ExceptionType MagickGetExceptionType(const MagickWand *wand)
+
+MagickGetIteratorIndex() returns the position of the iterator in the image list.
+ ssize_t MagickGetIteratorIndex(MagickWand *wand)
+
+MagickQueryConfigureOption() returns the value associated with the specified configure option.
+ char *MagickQueryConfigureOption(const char *option)
+
+MagickQueryConfigureOptions() returns any configure options that match the specified pattern (e.g. "*" for all). Options include NAME, VERSION, LIB_VERSION, etc.
+
+The format of the MagickQueryConfigureOptions function is:
+
+ char **MagickQueryConfigureOptions(const char *pattern,
+ size_t *number_options)
+
+A description of each parameter follows:
+pattern
+
+Specifies a pointer to a text string containing a pattern.
+number_options
+
+Returns the number of configure options in the list.
+
+
+
+MagickQueryFontMetrics() returns a 13 element array representing the following font metrics:
+
+ Element Description
+ -------------------------------------------------
+ 0 character width
+ 1 character height
+ 2 ascender
+ 3 descender
+ 4 text width
+ 5 text height
+ 6 maximum horizontal advance
+ 7 bounding box: x1
+ 8 bounding box: y1
+ 9 bounding box: x2
+ 10 bounding box: y2
+ 11 origin: x
+ 12 origin: y
+
+The format of the MagickQueryFontMetrics method is:
+
+ double *MagickQueryFontMetrics(MagickWand *wand,
+ const DrawingWand *drawing_wand,const char *text)
+
+A description of each parameter follows:
+wand
+
+the Magick wand.
+drawing_wand
+
+the drawing wand.
+text
+
+the text.
+
+
+MagickQueryMultilineFontMetrics() returns a 13 element array representing the following font metrics:
+
+ Element Description
+ -------------------------------------------------
+ 0 character width
+ 1 character height
+ 2 ascender
+ 3 descender
+ 4 text width
+ 5 text height
+ 6 maximum horizontal advance
+ 7 bounding box: x1
+ 8 bounding box: y1
+ 9 bounding box: x2
+ 10 bounding box: y2
+ 11 origin: x
+ 12 origin: y
+
+This method is like MagickQueryFontMetrics() but it returns the maximum text width and height for multiple lines of text.
+
+The format of the MagickQueryFontMetrics method is:
+
+ double *MagickQueryMultilineFontMetrics(MagickWand *wand,
+ const DrawingWand *drawing_wand,const char *text)
+
+A description of each parameter follows:
+wand
+
+the Magick wand.
+drawing_wand
+
+the drawing wand.
+text
+
+the text.
+
+
+
+MagickQueryFonts() returns any font that match the specified pattern (e.g. "*" for all).
+
+The format of the MagickQueryFonts function is:
+
+ char **MagickQueryFonts(const char *pattern,size_t *number_fonts)
+
+A description of each parameter follows:
+pattern
+
+Specifies a pointer to a text string containing a pattern.
+number_fonts
+
+Returns the number of fonts in the list.
+
+
+
+MagickQueryFonts() returns any image formats that match the specified pattern (e.g. "*" for all).
+
+The format of the MagickQueryFonts function is:
+
+ char **MagickQueryFonts(const char *pattern,
+ size_t *number_formats)
+
+A description of each parameter follows:
+pattern
+
+Specifies a pointer to a text string containing a pattern.
+number_formats
+
+This integer returns the number of image formats in the list.
+
+
+
+MagickRelinquishMemory() relinquishes memory resources returned by such methods as MagickIdentifyImage(), MagickGetException(), etc.
+
+The format of the MagickRelinquishMemory method is:
+
+ void *MagickRelinquishMemory(void *resource)
+
+A description of each parameter follows:
+resource
+
+Relinquish the memory associated with this resource.
+
+
+
+
+
+
+
+MagickSetFirstIterator() sets the wand iterator to the first image.
+
+After using any images added to the wand using MagickAddImage() or MagickReadImage() will be prepended before any image in the wand.
+
+Also the current image has been set to the first image (if any) in the Magick Wand. Using MagickNextImage() will then set teh current image to the second image in the list (if present).
+
+This operation is similar to MagickResetIterator() but differs in how MagickAddImage(), MagickReadImage(), and MagickNextImage() behaves afterward.
+
+The format of the MagickSetFirstIterator method is:
+
+ void MagickSetFirstIterator(MagickWand *wand)
+
+A description of each parameter follows:
+wand
+
+the magick wand.
+
+
+MagickSetIteratorIndex() set 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.
+
+If the index is invalid (range too large for number of images in wand) the function will return MagickFalse, but no 'exception' will be raised, as it is not actually an error. In that case the current image will not change.
+
+After using any images added to the wand using MagickAddImage() or MagickReadImage() will be added after the image indexed, regardless of if a zero (first image in list) or negative index (from end) is used.
+
+Jumping to index 0 is similar to MagickResetIterator() but differs in how MagickNextImage() behaves afterward.
+
+The format of the MagickSetIteratorIndex method is:
+
+ MagickBooleanType MagickSetIteratorIndex(MagickWand *wand,
+ const ssize_t index)
+
+A description of each parameter follows:
+wand
+
+the magick wand.
+index
+
+the scene number.
+
+
+
+MagickSetLastIterator() sets the wand iterator to the last image.
+
+The last image is actually the current image, and the next use of MagickPreviousImage() will not change this allowing this function to be used to iterate over the images in the reverse direction. In this sense it is more like MagickResetIterator() than MagickSetFirstIterator().
+
+Typically this function is used before MagickAddImage(), MagickReadImage() functions to ensure new images are appended to the very end of wand's image list.
+
+The format of the MagickSetLastIterator method is:
+
+ void MagickSetLastIterator(MagickWand *wand)
+
+A description of each parameter follows:
+wand
+
+the magick wand.
+
+-}
+
+-- * Image functions
+
+-- | MagickReadImage() reads an image or image sequence. The images are inserted at
+-- the current image pointer position. Use MagickSetFirstIterator(), MagickSetLastIterator,
+-- or MagickSetImageIndex() to specify the current image pointer position at the beginning
+-- of the image list, the end, or anywhere in-between respectively.
+
+foreign import ccall "wand/MagickWand.h MagickReadImage" magickReadImage
+ :: Ptr MagickWand -> CString -> IO MagickBooleanType
+
+-- | MagickNextImage() sets the next image in the wand as the current image.
+-- It is typically used after MagickResetIterator(), after which its first use will
+-- set the first image as the current image (unless the wand is empty).
+--
+-- It will return MagickFalse when no more images are left to be returned which
+-- happens when the wand is empty, or the current image is the last image.
+--
+-- When the above condition (end of image list) is reached, the iterator is
+-- automatically set so that you can start using MagickPreviousImage() to again
+-- iterate over the images in the reverse direction, starting with the last image
+-- (again). You can jump to this condition immeditally using MagickSetLastIterator().
+
+foreign import ccall "wand/MagickWand.h MagickNextImage" magickNextImage
+ :: Ptr MagickWand -> IO (MagickBooleanType)
+
+newtype FilterTypes = FilterTypes { unPCREOption :: CInt }
+ deriving (Eq,Show)
+
+#{enum FilterTypes, FilterTypes
+ , undefinedFilter = UndefinedFilter
+ , pointFilter = PointFilter
+ , boxFilter = BoxFilter
+ , triangleFilter = TriangleFilter
+ , hermiteFilter = HermiteFilter
+ , hanningFilter = HanningFilter
+ , hammingFilter = HammingFilter
+ , blackmanFilter = BlackmanFilter
+ , gaussianFilter = GaussianFilter
+ , qaudraticFilter = QuadraticFilter
+ , cubicFilter = CubicFilter
+ , catromFilter = CatromFilter
+ , mirchellFilter = MitchellFilter
+ , jincFilter = JincFilter
+ , sinkFilter = SincFilter
+ , sinkFastFilter = SincFastFilter
+ , kaiserFilter = KaiserFilter
+ , welshFilter = WelshFilter
+ , parzenFilter = ParzenFilter
+ , bohmanFilter = BohmanFilter
+ , bartlettFilter = BartlettFilter
+ , lagrangeFilter = LagrangeFilter
+ , lanczosFilter = LanczosFilter
+ , lanczosSharpFilter = LanczosSharpFilter
+ , lanczos2Filter = Lanczos2Filter
+ , lanczos2SharpFilter = Lanczos2SharpFilter
+ , robidouxFilter = RobidouxFilter
+}
+
+{-
+ ResizeFilter Bessel Blackman Box
+ Catrom CubicGaussian
+ Hanning Hermite Lanczos
+ Mitchell PointQuandratic
+ Sinc Triangle
+-}
+
+-- | MagickResizeImage() scales an image to the desired dimensions with one of these filters:
+--
+-- Most of the filters are FIR (finite impulse response), however, Bessel, Gaussian, and Sinc are
+-- IIR (infinite impulse response). Bessel and Sinc are windowed (brought down to zero) with the Blackman filter.
+
+foreign import ccall "wand/MagickWand.h MagickResizeImage" magickResizeImage
+ :: Ptr MagickWand
+ -> CInt -- ^ (size_t) columns
+ -> CInt -- ^ (size_t) rows
+ -> FilterTypes -- ^ filter
+ -> CDouble -- ^ blur factor where 1 > blurry, < 1 sharp
+ -> IO (MagickBooleanType)
+
+-- | MagickWriteImages() writes an image or image sequence.
+
+foreign import ccall "wand/MagickWand.h MagickWriteImages" magickWriteImages
+ :: Ptr MagickWand
+ -> CString -- ^ filename
+ -> MagickBooleanType -- ^ join images into a single multi-image file.
+ -> IO (MagickBooleanType)
+
103 LICENSE
@@ -0,0 +1,103 @@
+Before we get to the text of the license, lets just review what the license says in simple terms:
+
+It allows you to:
+
+ * freely download and use ImageMagick software, in whole or in part, for personal, company internal, or commercial purposes;
+ * use ImageMagick software in packages or distributions that you create;
+ * link against a library under a different license;
+ * link code under a different license against a library under this license;
+ * merge code into a work under a different license;
+ * extend patent grants to any code using code under this license;
+ * and extend patent protection.
+
+It forbids you to:
+
+ * redistribute any piece of ImageMagick-originated software without proper attribution;
+ * use any marks owned by ImageMagick Studio LLC in any way that might state or imply that ImageMagick Studio LLC endorses your distribution;
+ * use any marks owned by ImageMagick Studio LLC in any way that might state or imply that you created the ImageMagick software in question.
+
+It requires you to:
+
+ * include a copy of the license in any redistribution you may make that includes ImageMagick software;
+ * provide clear attribution to ImageMagick Studio LLC for any distributions that include ImageMagick software.
+
+It does not require you to:
+
+ * include the source of the ImageMagick software itself, or of any modifications you may have made to it, in any redistribution you may assemble that includes it;
+ * submit changes that you make to the software back to the ImageMagick Studio LLC (though such feedback is encouraged).
+
+A few other clarifications include:
+
+ * ImageMagick is freely available without charge;
+ * you may include ImageMagick on a DVD as long as you comply with the terms of the license;
+ * you can give modified code away for free or sell it under the terms of the ImageMagick license or distribute the result under a different license, but you need to acknowledge the use of the ImageMagick software;
+ * the license is compatible with the GPL V3.
+ * when exporting the ImageMagick software, review its export classification.
+
+Terms and Conditions for Use, Reproduction, and Distribution
+
+The legally binding and authoritative terms and conditions for use, reproduction, and distribution of ImageMagick follow:
+
+Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization dedicated to making software imaging solutions freely available.
+
+1. Definitions.
+
+License shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
+
+Licensor shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
+
+Legal Entity shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, control means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
+
+You (or Your) shall mean an individual or Legal Entity exercising permissions granted by this License.
+
+Source form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
+
+Object form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
+
+Work shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
+
+Derivative Works shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
+
+Contribution shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as Not a Contribution.
+
+Contributor shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
+
+2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
+
+ * You must give any other recipients of the Work or Derivative Works a copy of this License; and
+ * You must cause any modified files to carry prominent notices stating that You changed the files; and
+ * You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
+ * If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
+You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
+
+How to Apply the License to your Work
+
+To apply the ImageMagick License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information (don't include the brackets). The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the ImageMagick License (the "License"); you may not use
+ this file except in compliance with the License. You may obtain a copy
+ of the License at
+
+ http://www.imagemagick.org/script/license.php
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ License for the specific language governing permissions and limitations
+ under the License.
2  Setup.hs
@@ -0,0 +1,2 @@
+import Distribution.Simple
+main = defaultMain
18 examples/basic.hs
@@ -0,0 +1,18 @@
+import System.Environment
+import Graphics.ImageMagick.MagickWand.Internal -- TODO: types
+import Graphics.ImageMagick.MagickWand
+import Control.Monad
+import Filesystem.Path.CurrentOS
+
+
+main = do
+ [img,out] <- getArgs
+ withMagickWandGenesis $
+ withMagickWand $ do
+ stR <- readImage $ decodeString img
+-- unless stR $ throwWandException
+ magickIterate $ do
+ resizeImage 106 80 lanczosFilter 1.0
+ writeImages (decodeString out) True
+-- unless stW $ throwWandException
+
Please sign in to comment.
Something went wrong with that request. Please try again.