1""":mod:`wand.cdefs.magick_image` --- Magick-Image definitions
2~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3
4.. versionadded:: 0.5.0
5"""
6from ctypes import (CFUNCTYPE, POINTER, c_void_p, c_int, c_size_t, c_double,
7                    c_char_p, c_ubyte, c_bool)
8from wand.cdefs.wandtypes import c_ssize_t
9
10__all__ = ('MagickProgressMonitor', 'load')
11
12
13#: (:class:`ctypes.CFUNCTYPE`) a function type to allow ImageMagick's progress
14#: monitoring to call a python function. For example::
15#:
16#:     def myCallBack(filename, offset, size, user_data):
17#:         print(filename, offset, '/', size)
18#:         return True
19#:     iMyCallBack = MagickProgressMonitor(myCallBack)
20#:     library.MagickSetImageProgressMonitor(wand_instance,
21#:                                           iMyCallBack,
22#:                                           None)
23#:
24#: .. note::
25#:
26#:     TODO - Move to isolated module. This shouldn't be defined at time of
27#:     mload. It might be wiser to create a method to allow the user to ask for
28#:     C-function-type.
29MagickProgressMonitor = CFUNCTYPE(c_bool,
30                                  c_char_p,
31                                  c_ssize_t,
32                                  c_size_t,
33                                  c_void_p)
34
35
36def load(lib, IM_VERSION):
37    """Define Magick Image methods. The ImageMagick version is given as a
38    second argument for comparison. This will quick to determine which methods
39    are available from the library, and can be implemented as::
40
41        if IM_VERSION < 0x700:
42            # ... do ImageMagick-6 methods ...
43        else
44            # ... do ImageMagick-7 methods ...
45
46    .. seealso::
47
48        #include "wand/magick-image.h"
49        // Or
50        #include "MagickWand/magick-image.h"
51
52    :param lib: the loaded ``MagickWand`` library
53    :type lib: :class:`ctypes.CDLL`
54    :param IM_VERSION: the ImageMagick version number (i.e. 0x0689)
55    :type IM_VERSION: :class:`numbers.Integral`
56
57    .. versionadded:: 0.5.0
58
59    """
60    is_im_6 = IM_VERSION < 0x700
61    is_im_7 = IM_VERSION >= 0x700
62    lib.GetImageFromMagickWand.argtypes = [c_void_p]
63    lib.GetImageFromMagickWand.restype = c_void_p
64    lib.MagickAdaptiveBlurImage.argtypes = [c_void_p, c_double, c_double]
65    lib.MagickAdaptiveBlurImage.restype = c_bool
66    if is_im_6:
67        lib.MagickAdaptiveBlurImageChannel.argtypes = [
68            c_void_p, c_int, c_double, c_double
69        ]
70        lib.MagickAdaptiveBlurImageChannel.restype = c_bool
71    lib.MagickAdaptiveResizeImage.argtypes = [c_void_p, c_size_t, c_size_t]
72    lib.MagickAdaptiveResizeImage.restype = c_bool
73    lib.MagickAdaptiveSharpenImage.argtypes = [c_void_p, c_double, c_double]
74    lib.MagickAdaptiveSharpenImage.restype = c_bool
75    if is_im_6:
76        lib.MagickAdaptiveSharpenImageChannel.argtypes = [
77            c_void_p, c_int, c_double, c_double
78        ]
79        lib.MagickAdaptiveSharpenImageChannel.restype = c_bool
80    if is_im_6:
81        lib.MagickAdaptiveThresholdImage.argtypes = [
82            c_void_p, c_size_t, c_size_t, c_ssize_t
83        ]
84        lib.MagickAdaptiveThresholdImage.restype = c_bool
85    else:
86        lib.MagickAdaptiveThresholdImage.argtypes = [
87            c_void_p, c_size_t, c_size_t, c_double
88        ]
89        lib.MagickAdaptiveThresholdImage.restype = c_bool
90    lib.MagickAddImage.argtypes = [c_void_p, c_void_p]
91    lib.MagickAddImage.restype = c_bool
92    if is_im_6:
93        lib.MagickAddNoiseImage.argtypes = [c_void_p, c_int]
94        lib.MagickAddNoiseImage.restype = c_bool
95    else:
96        lib.MagickAddNoiseImage.argtypes = [c_void_p, c_int, c_double]
97        lib.MagickAddNoiseImage.restype = c_bool
98    if is_im_6:
99        lib.MagickAddNoiseImageChannel.argtypes = [c_void_p, c_int, c_int]
100        lib.MagickAddNoiseImageChannel.restype = c_bool
101    lib.MagickAffineTransformImage.argtypes = [c_void_p, c_void_p]
102    lib.MagickAffineTransformImage.restype = c_bool
103    lib.MagickAnnotateImage.argtypes = [
104        c_void_p, c_void_p, c_double, c_double, c_double, c_char_p
105    ]
106    lib.MagickAnnotateImage.restype = c_int
107    lib.MagickAnimateImages.argtypes = [c_void_p, c_char_p]
108    lib.MagickAnimateImages.restype = c_bool
109    lib.MagickAppendImages.argtypes = [c_void_p, c_int]
110    lib.MagickAppendImages.restype = c_void_p
111    lib.MagickAutoGammaImage.argtypes = [c_void_p]
112    lib.MagickAutoGammaImage.restype = c_bool
113    if is_im_6:
114        lib.MagickAutoGammaImageChannel.argtypes = [c_void_p, c_int]
115        lib.MagickAutoGammaImageChannel.restype = c_bool
116    lib.MagickAutoLevelImage.argtypes = [c_void_p]
117    lib.MagickAutoLevelImage.restype = c_bool
118    if is_im_6:
119        lib.MagickAutoLevelImageChannel.argtypes = [c_void_p, c_int]
120        lib.MagickAutoLevelImageChannel.restype = c_bool
121    try:
122        lib.MagickAutoOrientImage.argtypes = [c_void_p]
123    except AttributeError:
124        # MagickAutoOrientImage was added in 6.8.9+, we have a fallback
125        # function, so we pass silently if we cannot import it.
126        pass
127    if IM_VERSION >= 0x708:
128        try:
129            lib.MagickAutoThresholdImage.argtypes = [c_void_p, c_int]
130            lib.MagickAutoThresholdImage.restype = c_bool
131        except AttributeError:
132            lib.MagickAutoThresholdImage = None
133    else:
134        lib.MagickAutoThresholdImage = None
135    lib.MagickBlackThresholdImage.argtypes = [c_void_p, c_void_p]
136    lib.MagickBlackThresholdImage.restype = c_bool
137    lib.MagickBlueShiftImage.argtypes = [c_void_p, c_double]
138    lib.MagickBlueShiftImage.restype = c_bool
139    lib.MagickBlurImage.argtypes = [c_void_p, c_double, c_double]
140    lib.MagickBlurImage.restype = c_bool
141    if is_im_6:
142        lib.MagickBlurImageChannel.argtypes = [c_void_p, c_int, c_double,
143                                               c_double]
144        lib.MagickBlurImageChannel.restype = c_bool
145    border_image_args = [c_void_p, c_void_p, c_size_t, c_size_t]
146    if is_im_7:
147        border_image_args.append(c_int)
148    lib.MagickBorderImage.argtypes = border_image_args
149    lib.MagickBorderImage.restype = c_bool
150    lib.MagickBrightnessContrastImage.argtypes = [c_void_p, c_double, c_double]
151    lib.MagickBrightnessContrastImage.restype = c_bool
152    if is_im_6:
153        lib.MagickBrightnessContrastImageChannel.argtypes = [
154            c_void_p, c_int, c_double, c_double
155        ]
156        lib.MagickBrightnessContrastImageChannel.restype = c_bool
157    if IM_VERSION >= 0x708:
158        try:
159            lib.MagickCannyEdgeImage.argtypes = [c_void_p, c_double, c_double,
160                                                 c_double, c_double]
161            lib.MagickCannyEdgeImage.restype = c_bool
162        except AttributeError:
163            lib.MagickCannyEdgeImage = None
164    else:
165        lib.MagickCannyEdgeImage = None
166    lib.MagickCharcoalImage.argtypes = [c_void_p, c_double, c_double]
167    lib.MagickCharcoalImage.restype = c_bool
168    lib.MagickChopImage.argtypes = [
169        c_void_p, c_size_t, c_size_t, c_ssize_t, c_ssize_t
170    ]
171    lib.MagickChopImage.restype = c_bool
172    if is_im_7:
173        try:
174            lib.MagickCLAHEImage.argtypes = [c_void_p, c_size_t, c_size_t,
175                                             c_double, c_double]
176            lib.MagickCLAHEImage.restype = c_bool
177        except AttributeError:
178            lib.MagickCLAHEImage = None
179    else:
180        lib.MagickCLAHEImage = None
181    lib.MagickClampImage.argtypes = [c_void_p]
182    lib.MagickClampImage.restype = c_bool
183    if is_im_6:
184        lib.MagickClampImageChannel.argtypes = [c_void_p, c_int]
185        lib.MagickClampImageChannel.restype = c_bool
186    lib.MagickClipImage.argtypes = [c_void_p]
187    lib.MagickClipImage.restype = c_bool
188    lib.MagickClipImagePath.argtypes = [c_void_p, c_char_p, c_bool]
189    lib.MagickClipImagePath.restype = c_bool
190    if is_im_7:
191        lib.MagickClutImage.argtypes = [c_void_p, c_void_p, c_int]
192        lib.MagickClutImage.restype = c_bool
193    else:
194        lib.MagickClutImage.argtypes = [c_void_p, c_void_p]
195        lib.MagickClutImage.restype = c_bool
196    if is_im_6:
197        lib.MagickClutImageChannel.argtypes = [c_void_p, c_int, c_void_p]
198        lib.MagickClutImageChannel.restype = c_bool
199    lib.MagickCoalesceImages.argtypes = [c_void_p]
200    lib.MagickCoalesceImages.restype = c_void_p
201    lib.MagickColorDecisionListImage.argtypes = [c_void_p, c_char_p]
202    lib.MagickColorDecisionListImage.restype = c_bool
203    lib.MagickColorizeImage.argtypes = [c_void_p, c_void_p, c_void_p]
204    lib.MagickColorizeImage.restype = c_bool
205    lib.MagickColorMatrixImage.argtypes = [c_void_p, c_void_p]
206    lib.MagickColorMatrixImage.restype = c_bool
207    if IM_VERSION > 0x709:
208        lib.MagickColorThresholdImage.argtypes = [c_void_p, c_void_p, c_void_p]
209        lib.MagickColorThresholdImage.restype = c_bool
210    else:
211        lib.MagickColorThresholdImage = None
212    lib.MagickCommentImage.argtypes = [c_void_p, c_char_p]
213    lib.MagickCommentImage.restype = c_bool
214    lib.MagickCombineImages.argtypes = [c_void_p, c_int]
215    lib.MagickCombineImages.restype = c_void_p
216    if is_im_6:
217        lib.MagickCompareImageChannels.argtypes = [
218            c_void_p, c_void_p, c_int, c_double
219        ]
220        lib.MagickCompareImageChannels.restype = c_void_p
221        lib.MagickCompareImageLayers.argtypes = [c_void_p, c_int]
222        lib.MagickCompareImageLayers.restype = c_void_p
223    lib.MagickCompareImages.argtypes = [
224        c_void_p, c_void_p, c_int, POINTER(c_double)
225    ]
226    lib.MagickCompareImages.restype = c_void_p
227    if is_im_6:
228        try:
229            lib.MagickCompareImageLayers.argtypes = [c_void_p, c_int]
230            lib.MagickCompareImageLayers.restype = c_void_p
231        except AttributeError:
232            lib.MagickCompareImageLayers = None
233    else:
234        try:
235            lib.MagickCompareImagesLayers.argtypes = [c_void_p, c_int]
236            lib.MagickCompareImagesLayers.restype = c_void_p
237        except AttributeError:
238            lib.MagickCompareImagesLayers = None
239    if IM_VERSION >= 0x708:
240        try:
241            lib.MagickComplexImages.argtypes = [c_void_p, c_int]
242            lib.MagickComplexImages.restype = c_void_p
243        except AttributeError:
244            lib.MagickComplexImages = None
245    else:
246        lib.MagickComplexImages = None
247    if is_im_6:
248        lib.MagickCompositeImage.argtypes = [
249            c_void_p, c_void_p, c_int, c_ssize_t, c_ssize_t
250        ]
251    else:
252        lib.MagickCompositeImage.argtypes = [
253            c_void_p, c_void_p, c_int, c_bool, c_ssize_t, c_ssize_t
254        ]
255    lib.MagickCompositeImage.restype = c_bool
256    try:
257        lib.MagickCompositeLayers.argtypes = [
258            c_void_p, c_void_p, c_int, c_ssize_t, c_ssize_t
259        ]
260        lib.MagickCompositeLayers.restype = c_bool
261    except AttributeError:
262        lib.MagickCompositeLayers = None
263    if is_im_6:
264        lib.MagickCompositeImageChannel.argtypes = [
265            c_void_p, c_int, c_void_p, c_int, c_ssize_t, c_ssize_t
266        ]
267        lib.MagickCompositeImageChannel.restype = c_bool
268    else:
269        lib.MagickCompositeImageChannel = None
270    if IM_VERSION >= 0x708:
271        try:
272            lib.MagickConnectedComponentsImage.argtypes = [
273                c_void_p, c_size_t, POINTER(c_void_p)
274            ]
275            lib.MagickConnectedComponentsImage.restype = c_bool
276        except AttributeError:
277            lib.MagickConnectedComponentsImage = None
278    else:
279        lib.MagickConnectedComponentsImage = None
280    lib.MagickConstituteImage.argtypes = [
281        c_void_p, c_size_t, c_size_t, c_char_p, c_int, c_void_p
282    ]
283    lib.MagickContrastImage.argtypes = [c_void_p, c_bool]
284    lib.MagickContrastImage.restype = c_bool
285    lib.MagickContrastStretchImage.argtypes = [c_void_p, c_double, c_double]
286    if is_im_6:
287        lib.MagickContrastStretchImageChannel.argtypes = [
288            c_void_p, c_int, c_double, c_double
289        ]
290    else:
291        lib.MagickContrastStretchImageChannel = None
292    lib.MagickConvolveImage.argtypes = [c_void_p, c_size_t, c_double]
293    lib.MagickConvolveImage.restype = c_bool
294    if is_im_6:
295        lib.MagickConvolveImageChannel.argtypes = [
296            c_void_p, c_int, c_size_t, c_double
297        ]
298        lib.MagickConvolveImageChannel.restype = c_bool
299    lib.MagickCropImage.argtypes = [
300        c_void_p, c_size_t, c_size_t, c_ssize_t, c_ssize_t
301    ]
302    lib.MagickCropImage.restype = c_bool
303    lib.MagickCycleColormapImage.argtypes = [c_void_p, c_ssize_t]
304    lib.MagickCycleColormapImage.restype = c_bool
305    lib.MagickDecipherImage.argtypes = [c_void_p, c_char_p]
306    lib.MagickDecipherImage.restype = c_bool
307    lib.MagickDeconstructImages.argtypes = [c_void_p]
308    lib.MagickDeconstructImages.restype = c_void_p
309    lib.MagickDeskewImage.argtypes = [c_void_p, c_double]
310    lib.MagickDeskewImage.restype = c_bool
311    lib.MagickDespeckleImage.argtypes = [c_void_p]
312    lib.MagickDespeckleImage.restype = c_bool
313    lib.MagickDestroyImage.argtypes = [c_void_p]
314    lib.MagickDestroyImage.restype = c_void_p
315    lib.MagickDisplayImage.argtypes = [c_void_p, c_char_p]
316    lib.MagickDisplayImage.restype = c_bool
317    lib.MagickDisplayImages.argtypes = [c_void_p, c_char_p]
318    lib.MagickDisplayImages.restype = c_bool
319    lib.MagickDistortImage.argtypes = [
320        c_void_p, c_int, c_size_t, POINTER(c_double), c_int
321    ]
322    lib.MagickDistortImage.restype = c_int
323    lib.MagickDrawImage.argtypes = [c_void_p, c_void_p]
324    lib.MagickDrawImage.restype = c_int
325    lib.MagickEdgeImage.argtypes = [c_void_p, c_double]
326    lib.MagickEdgeImage.restype = c_bool
327    lib.MagickEmbossImage.argtypes = [c_void_p, c_double, c_double]
328    lib.MagickEmbossImage.restype = c_bool
329    lib.MagickEncipherImage.argtypes = [c_void_p, c_char_p]
330    lib.MagickEncipherImage.restype = c_bool
331    lib.MagickEnhanceImage.argtypes = [c_void_p]
332    lib.MagickEnhanceImage.restype = c_bool
333    lib.MagickEqualizeImage.argtypes = [c_void_p]
334    lib.MagickEqualizeImage.restype = c_bool
335    if is_im_6:
336        lib.MagickEqualizeImageChannel.argtypes = [c_void_p, c_int]
337        lib.MagickEqualizeImageChannel.restype = c_bool
338    lib.MagickEvaluateImage.argtypes = [c_void_p, c_int, c_double]
339    if is_im_6:
340        lib.MagickEvaluateImageChannel.argtypes = [
341            c_void_p, c_int, c_int, c_double
342        ]
343    else:
344        lib.MagickEvaluateImageChannel = None
345    lib.MagickEvaluateImages.argtypes = [c_void_p, c_int]
346    lib.MagickEvaluateImages.restype = c_void_p
347    lib.MagickExportImagePixels.argtypes = [
348        c_void_p, c_ssize_t, c_ssize_t, c_size_t, c_size_t, c_char_p, c_int,
349        c_void_p
350    ]
351    lib.MagickExportImagePixels.restype = c_bool
352    lib.MagickExtentImage.argtypes = [
353        c_void_p, c_size_t, c_size_t, c_ssize_t, c_ssize_t
354    ]
355    lib.MagickExtentImage.restype = c_bool
356    if is_im_6:
357        lib.MagickFilterImage.argtypes = [c_void_p, c_void_p]
358        lib.MagickFilterImage.restype = c_bool
359        lib.MagickFilterImageChannel.argtypes = [c_void_p, c_int, c_void_p]
360        lib.MagickFilterImageChannel.restype = c_bool
361    lib.MagickFlipImage.argtypes = [c_void_p]
362    lib.MagickFlipImage.restype = c_bool
363    lib.MagickFloodfillPaintImage.argtypes = [
364        c_void_p, c_int, c_void_p, c_double, c_void_p, c_ssize_t, c_ssize_t,
365        c_bool
366    ]
367    lib.MagickFloodfillPaintImage.restype = c_bool
368    lib.MagickFlopImage.argtypes = [c_void_p]
369    lib.MagickFlopImage.restype = c_bool
370    lib.MagickForwardFourierTransformImage.argtypes = [c_void_p, c_bool]
371    lib.MagickForwardFourierTransformImage.restype = c_bool
372    if is_im_6:
373        lib.MagickFrameImage.argtypes = [
374            c_void_p, c_void_p, c_size_t, c_size_t, c_ssize_t, c_ssize_t
375        ]
376    else:
377        lib.MagickFrameImage.argtypes = [
378            c_void_p, c_void_p, c_size_t, c_size_t, c_ssize_t, c_ssize_t,
379            c_int
380        ]
381    lib.MagickFrameImage.restype = c_bool
382    lib.MagickFunctionImage.argtypes = [
383        c_void_p, c_int, c_size_t, POINTER(c_double)
384    ]
385    lib.MagickFunctionImage.restype = c_bool
386    if is_im_6:
387        lib.MagickFunctionImageChannel.argtypes = [
388            c_void_p, c_int, c_int, c_size_t, POINTER(c_double)
389        ]
390        lib.MagickFunctionImageChannel.restype = c_bool
391    else:
392        lib.MagickFunctionImageChannel = None
393    lib.MagickFxImage.argtypes = [c_void_p, c_char_p]
394    lib.MagickFxImage.restype = c_void_p
395    if is_im_6:
396        lib.MagickFxImageChannel.argtypes = [c_void_p, c_int, c_char_p]
397        lib.MagickFxImageChannel.restype = c_void_p
398    else:
399        lib.MagickFxImageChannel = None
400    lib.MagickGammaImage.argtypes = [c_void_p, c_double]
401    lib.MagickGammaImage.restype = c_bool
402    if is_im_6:
403        lib.MagickGammaImageChannel.argtypes = [c_void_p, c_int, c_double]
404        lib.MagickGammaImageChannel.restype = c_bool
405    else:
406        lib.MagickGammaImageChannel = None
407    lib.MagickGaussianBlurImage.argtypes = [c_void_p, c_double, c_double]
408    lib.MagickGaussianBlurImage.restype = c_bool
409    if is_im_6:
410        lib.MagickGaussianBlurImageChannel.argtypes = [
411            c_void_p, c_int, c_double, c_double
412        ]
413        lib.MagickGaussianBlurImageChannel.restype = c_bool
414    else:
415        lib.MagickGaussianBlurImageChannel = None
416    lib.MagickGetImage.argtypes = [c_void_p]
417    lib.MagickGetImage.restype = c_void_p
418    lib.MagickGetImageAlphaChannel.argtypes = [c_void_p]
419    lib.MagickGetImageAlphaChannel.restype = c_bool
420    lib.MagickGetImageBackgroundColor.argtypes = [c_void_p, c_void_p]
421    lib.MagickGetImageBackgroundColor.restype = c_bool
422    lib.MagickGetImageBlob.argtypes = [c_void_p, POINTER(c_size_t)]
423    lib.MagickGetImageBlob.restype = POINTER(c_ubyte)
424    if is_im_6:
425        lib.MagickGetImageBluePrimary.argtypes = [
426            c_void_p, POINTER(c_double), POINTER(c_double)
427        ]
428    else:
429        lib.MagickGetImageBluePrimary.argtypes = [
430            c_void_p, POINTER(c_double), POINTER(c_double), POINTER(c_double)
431        ]
432    lib.MagickGetImageBluePrimary.restype = c_bool
433    lib.MagickGetImageBorderColor.argtypes = [c_void_p, c_void_p]
434    lib.MagickGetImageBorderColor.restype = c_bool
435    if is_im_6:
436        lib.MagickGetImageChannelDepth.argtypes = [c_void_p, c_int]
437        lib.MagickGetImageChannelDepth.restype = c_size_t
438        lib.MagickGetImageChannelFeatures.argtypes = [c_void_p, c_size_t]
439        lib.MagickGetImageChannelFeatures.restype = c_void_p
440        lib.MagickGetImageChannelKurtosis.argtypes = [
441            c_void_p, c_int, POINTER(c_double), POINTER(c_double)
442        ]
443        lib.MagickGetImageChannelKurtosis.restype = c_bool
444        lib.MagickGetImageChannelMean.argtypes = [
445            c_void_p, c_int, POINTER(c_double), POINTER(c_double)
446        ]
447        lib.MagickGetImageChannelMean.restype = c_bool
448        lib.MagickGetImageChannelRange.argtypes = [
449            c_void_p, c_int, POINTER(c_double), POINTER(c_double)
450        ]
451        lib.MagickGetImageChannelRange.restype = c_bool
452        lib.MagickGetImageChannelStatistics.argtypes = [c_void_p]
453        lib.MagickGetImageChannelStatistics.restype = c_void_p
454        lib.MagickGetImageClipMask.argtypes = [c_void_p]
455        lib.MagickGetImageClipMask.restype = c_void_p
456    else:
457        lib.MagickGetImageChannelDepth = None
458    lib.MagickGetImageColormapColor.argtypes = [c_void_p, c_size_t, c_void_p]
459    lib.MagickGetImageColormapColor.restype = c_bool
460    lib.MagickGetImageColors.argtypes = [c_void_p]
461    lib.MagickGetImageColors.restype = c_size_t
462    lib.MagickGetImageColorspace.argtypes = [c_void_p]
463    lib.MagickGetImageColorspace.restype = c_int
464    lib.MagickGetImageCompose.argtypes = [c_void_p]
465    lib.MagickGetImageCompose.restype = c_int
466    lib.MagickGetImageCompression.argtypes = [c_void_p]
467    lib.MagickGetImageCompression.restype = c_int
468    lib.MagickGetImageCompressionQuality.argtypes = [c_void_p]
469    lib.MagickGetImageCompressionQuality.restype = c_ssize_t
470    try:
471        lib.MagickGetImageEndian.argtypes = [c_void_p]
472        lib.MagickGetImageEndian.restype = c_int
473    except AttributeError:
474        lib.MagickGetImageEndian = None
475    lib.MagickGetImageDelay.argtypes = [c_void_p]
476    lib.MagickGetImageDelay.restype = c_size_t
477    lib.MagickGetImageDepth.argtypes = [c_void_p]
478    lib.MagickGetImageDepth.restype = c_size_t
479    lib.MagickGetImageDispose.argtypes = [c_void_p]
480    lib.MagickGetImageDispose.restype = c_int
481    lib.MagickGetImageDistortion.argtypes = [
482        c_void_p, c_void_p, c_int, POINTER(c_double)
483    ]
484    lib.MagickGetImageDistortion.restype = c_bool
485    if is_im_7:
486        lib.MagickGetImageFeatures.argtypes = [c_void_p, c_size_t]
487        lib.MagickGetImageFeatures.restype = c_void_p
488    lib.MagickGetImageFilename.argtypes = [c_void_p]
489    lib.MagickGetImageFilename.restype = c_void_p
490    lib.MagickGetImageFormat.argtypes = [c_void_p]
491    lib.MagickGetImageFormat.restype = c_void_p
492    lib.MagickGetImageFuzz.argtypes = [c_void_p]
493    lib.MagickGetImageFuzz.restype = c_double
494    lib.MagickGetImageGamma.argtypes = [c_void_p]
495    lib.MagickGetImageGamma.restype = c_double
496    lib.MagickGetImageGravity.argtypes = [c_void_p]
497    lib.MagickGetImageGravity.restype = c_int
498    if is_im_6:
499        lib.MagickGetImageGreenPrimary.argtypes = [
500            c_void_p, POINTER(c_double), POINTER(c_double)
501        ]
502    else:
503        lib.MagickGetImageGreenPrimary.argtypes = [
504            c_void_p, POINTER(c_double), POINTER(c_double), POINTER(c_double)
505        ]
506    lib.MagickGetImageGreenPrimary.restype = c_bool
507    lib.MagickGetImageHeight.argtypes = [c_void_p]
508    lib.MagickGetImageHeight.restype = c_size_t
509    lib.MagickGetImageHistogram.argtypes = [c_void_p, POINTER(c_size_t)]
510    lib.MagickGetImageHistogram.restype = POINTER(c_void_p)
511    lib.MagickGetImageInterlaceScheme.argtypes = [c_void_p]
512    lib.MagickGetImageInterlaceScheme.restype = c_int
513    lib.MagickGetImageIterations.argtypes = [c_void_p]
514    lib.MagickGetImageIterations.restype = c_size_t
515    lib.MagickGetImageInterpolateMethod.argtypes = [c_void_p]
516    lib.MagickGetImageInterpolateMethod.restype = c_int
517    if is_im_7:
518        lib.MagickGetImageKurtosis.argtypes = [
519            c_void_p, POINTER(c_double), POINTER(c_double)
520        ]
521        lib.MagickGetImageKurtosis.restype = c_bool
522    lib.MagickGetImageLength.argtypes = [c_void_p, POINTER(c_size_t)]
523    lib.MagickGetImageLength.restype = c_bool
524    if is_im_7:
525        lib.MagickGetImageMask.argtypes = [c_void_p, c_int]
526        lib.MagickGetImageMask.restype = c_void_p
527    else:
528        lib.MagickGetImageMask = None
529    lib.MagickGetImageMatteColor.argtypes = [c_void_p, c_void_p]
530    lib.MagickGetImageMatteColor.restype = c_bool
531    if is_im_7:
532        lib.MagickGetImageMean.argtypes = [
533            c_void_p, POINTER(c_double), POINTER(c_double)
534        ]
535        lib.MagickGetImageMean.restype = c_bool
536    lib.MagickGetImageOrientation.argtypes = [c_void_p]
537    lib.MagickGetImageOrientation.restype = c_int
538    lib.MagickGetImagePage.argtypes = [
539        c_void_p, POINTER(c_size_t), POINTER(c_size_t), POINTER(c_ssize_t),
540        POINTER(c_ssize_t)
541    ]
542    lib.MagickGetImagePage.restype = c_bool
543    lib.MagickGetImagePixelColor.argtypes = [
544        c_void_p, c_ssize_t, c_ssize_t, c_void_p
545    ]
546    lib.MagickGetImagePixelColor.restype = c_bool
547    lib.MagickGetImageRange.argtypes = [
548        c_void_p, POINTER(c_double), POINTER(c_double)
549    ]
550    lib.MagickGetImageRange.restype = c_bool
551    if is_im_6:
552        lib.MagickGetImageRedPrimary.argtypes = [
553            c_void_p, POINTER(c_double), POINTER(c_double)
554        ]
555    else:
556        lib.MagickGetImageRedPrimary.argtypes = [
557            c_void_p, POINTER(c_double), POINTER(c_double), POINTER(c_double)
558        ]
559    lib.MagickGetImageRedPrimary.restype = c_bool
560    lib.MagickGetImageRegion.argtypes = [
561        c_void_p, c_size_t, c_size_t, c_ssize_t, c_ssize_t
562    ]
563    lib.MagickGetImageRegion.restype = c_void_p
564    lib.MagickGetImageResolution.argtypes = [
565        c_void_p, POINTER(c_double), POINTER(c_double)
566    ]
567    lib.MagickGetImageRenderingIntent.argtypes = [c_void_p]
568    lib.MagickGetImageRenderingIntent.restype = c_int
569    lib.MagickGetImageResolution.argtypes = [
570        c_void_p, POINTER(c_double), POINTER(c_double)
571    ]
572    lib.MagickGetImageResolution.restype = c_bool
573    lib.MagickGetImagesBlob.argtypes = [c_void_p, POINTER(c_size_t)]
574    lib.MagickGetImagesBlob.restype = POINTER(c_ubyte)
575    lib.MagickGetImageScene.argtypes = [c_void_p]
576    lib.MagickGetImageScene.restype = c_size_t
577    lib.MagickGetImageSignature.argtypes = [c_void_p]
578    lib.MagickGetImageSignature.restype = c_void_p
579    lib.MagickGetImageTicksPerSecond.argtypes = [c_void_p]
580    lib.MagickGetImageTicksPerSecond.restype = c_size_t
581    lib.MagickGetImageTotalInkDensity.argtypes = [c_void_p]
582    lib.MagickGetImageTotalInkDensity.restype = c_double
583    lib.MagickGetImageType.argtypes = [c_void_p]
584    lib.MagickGetImageType.restype = c_int
585    lib.MagickGetImageUnits.argtypes = [c_void_p]
586    lib.MagickGetImageVirtualPixelMethod.argtypes = [c_void_p]
587    if is_im_6:
588        lib.MagickGetImageWhitePoint.argtypes = [
589            c_void_p, POINTER(c_double), POINTER(c_double)
590        ]
591    else:
592        lib.MagickGetImageWhitePoint.argtypes = [
593            c_void_p, POINTER(c_double), POINTER(c_double), POINTER(c_double)
594        ]
595    lib.MagickGetImageWhitePoint.restype = c_bool
596    lib.MagickGetImageWidth.argtypes = [c_void_p]
597    lib.MagickGetImageWidth.restype = c_size_t
598    lib.MagickGetNumberImages.argtypes = [c_void_p]
599    lib.MagickGetNumberImages.restype = c_size_t
600    lib.MagickHaldClutImage.argtypes = [c_void_p, c_void_p]
601    lib.MagickHaldClutImage.restype = c_bool
602    if is_im_6:
603        lib.MagickHaldClutImageChannel.argtypes = [c_void_p, c_int, c_void_p]
604        lib.MagickHaldClutImageChannel.restype = c_bool
605    else:
606        lib.MagickHaldClutImageChannel = None
607    lib.MagickHasNextImage.argtypes = [c_void_p]
608    lib.MagickHasNextImage.restype = c_bool
609    lib.MagickHasPreviousImage.argtypes = [c_void_p]
610    lib.MagickHasPreviousImage.restype = c_bool
611    if IM_VERSION >= 0x708:
612        try:
613            lib.MagickHoughLineImage.argtypes = [c_void_p, c_size_t, c_size_t,
614                                                 c_size_t]
615            lib.MagickHoughLineImage.restype = c_bool
616        except AttributeError:
617            lib.MagickHoughLineImage = None
618    else:
619        lib.MagickHoughLineImage = None
620    lib.MagickIdentifyImage.argtypes = [c_void_p]
621    lib.MagickIdentifyImage.restype = c_void_p
622    if is_im_6:
623        lib.MagickImplodeImage.argtypes = [c_void_p, c_double]
624    else:
625        lib.MagickImplodeImage.argtypes = [c_void_p, c_double, c_int]
626    lib.MagickImplodeImage.restype = c_bool
627    lib.MagickImportImagePixels.argtypes = [
628        c_void_p, c_ssize_t, c_ssize_t, c_size_t, c_size_t, c_char_p, c_int,
629        c_void_p
630    ]
631    lib.MagickImportImagePixels.restype = c_bool
632    lib.MagickInverseFourierTransformImage.argtypes = [
633        c_void_p, c_void_p, c_double
634    ]
635    lib.MagickInverseFourierTransformImage.restype = c_bool
636    if IM_VERSION > 0x709:
637        try:
638            lib.MagickKmeansImage.argtypes = [
639                c_void_p, c_size_t, c_size_t, c_double
640            ]
641            lib.MagickKmeansImage.restype = c_bool
642        except AttributeError:
643            lib.MagickKmeansImage = None
644    else:
645        lib.MagickKmeansImage = None
646    if IM_VERSION >= 0x708:
647        try:
648            lib.MagickKuwaharaImage.argtypes = [c_void_p, c_double, c_double]
649            lib.MagickKuwaharaImage.restype = c_bool
650        except AttributeError:
651            lib.MagickKuwaharaImage = None
652    else:
653        lib.MagickKuwaharaImage = None
654    lib.MagickLabelImage.argtypes = [c_void_p, c_char_p]
655    lib.MagickLabelImage.restype = c_bool
656    lib.MagickLevelImage.argtypes = [c_void_p, c_double, c_double, c_double]
657    lib.MagickLevelImage.restype = c_bool
658    if is_im_6:
659        lib.MagickLevelImageChannel.argtypes = [
660            c_void_p, c_int, c_double, c_double, c_double
661        ]
662        lib.MagickLevelImageChannel.restype = c_bool
663    else:
664        lib.MagickLevelImageChannel = None
665    if IM_VERSION >= 0x708:
666        try:
667            lib.MagickLevelImageColors.argtypes = [
668                c_void_p, c_void_p, c_void_p, c_bool
669            ]
670            lib.MagickLevelImageColors.restype = c_bool
671        except AttributeError:
672            lib.MagickLevelImageColors = None
673        try:
674            lib.MagickLevelizeImage.argtypes = [c_void_p, c_double, c_double,
675                                                c_double]
676            lib.MagickLevelizeImage.restype = c_bool
677        except AttributeError:
678            lib.MagickLevelizeImage = None
679    else:
680        lib.MagickLevelImageColors = None
681        lib.MagickLevelizeImage = None
682    lib.MagickLinearStretchImage.argtypes = [c_void_p, c_double, c_double]
683    lib.MagickLinearStretchImage.restype = c_bool
684    lib.MagickLiquidRescaleImage.argtypes = [
685        c_void_p, c_size_t, c_size_t, c_double, c_double
686    ]
687    lib.MagickLiquidRescaleImage.restype = c_bool
688    try:
689        lib.MagickLocalContrastImage.argtypes = [c_void_p, c_double, c_double]
690        lib.MagickLocalContrastImage.restype = c_bool
691    except AttributeError:
692        lib.MagickLocalContrastImage = None
693    lib.MagickMagnifyImage.argtypes = [c_void_p]
694    lib.MagickMagnifyImage.restype = c_bool
695    if IM_VERSION >= 0x708:
696        try:
697            lib.MagickMeanShiftImage.argtypes = [c_void_p, c_size_t, c_size_t,
698                                                 c_double]
699            lib.MagickMeanShiftImage.restype = c_bool
700        except AttributeError:
701            lib.MagickMeanShiftImage = None
702    else:
703        lib.MagickMeanShiftImage = None
704    if is_im_6:
705        lib.MagickMedianFilterImage.argtypes = [c_void_p, c_double]
706        lib.MagickMedianFilterImage.restype = c_bool
707    lib.MagickMergeImageLayers.argtypes = [c_void_p, c_int]
708    lib.MagickMergeImageLayers.restype = c_void_p
709    lib.MagickMinifyImage.argtypes = [c_void_p]
710    lib.MagickMinifyImage.restype = c_bool
711    try:
712        lib.MagickModeImage.argtypes = [c_void_p, c_double]
713        lib.MagickModeImage.restype = c_bool
714    except AttributeError:
715        pass
716    lib.MagickModulateImage.argtypes = [c_void_p, c_double, c_double, c_double]
717    lib.MagickModulateImage.restype = c_bool
718    lib.MagickMontageImage.argtypes = [
719        c_void_p, c_void_p, c_char_p, c_char_p, c_int, c_char_p
720    ]
721    lib.MagickMontageImage.restype = c_void_p
722    lib.MagickMorphImages.argtypes = [c_void_p, c_size_t]
723    lib.MagickMorphImages.restype = c_void_p
724    lib.MagickMorphologyImage.argtypes = [c_void_p, c_int, c_ssize_t, c_void_p]
725    lib.MagickMorphologyImage.restype = c_bool
726    if is_im_6:
727        lib.MagickMorphologyImageChannel.argtypes = [
728            c_void_p, c_int, c_int, c_ssize_t, c_void_p
729        ]
730        lib.MagickMorphologyImageChannel.restype = c_bool
731    else:
732        lib.MagickMorphologyImageChannel = None
733    lib.MagickMotionBlurImage.argtypes = [
734        c_void_p, c_double, c_double, c_double
735    ]
736    lib.MagickMotionBlurImage.restype = c_bool
737    if is_im_6:
738        lib.MagickMotionBlurImageChannel.argtypes = [
739            c_void_p, c_int, c_double, c_double, c_double
740        ]
741        lib.MagickMotionBlurImageChannel.restype = c_bool
742    else:
743        lib.MagickMotionBlurImageChannel = None
744    lib.MagickNegateImage.argtypes = [c_void_p, c_int]
745    lib.MagickNegateImage.restype = c_bool
746    if is_im_6:
747        lib.MagickNegateImageChannel.argtypes = [c_void_p, c_int, c_int]
748        lib.MagickNegateImageChannel.restype = c_bool
749    else:
750        lib.MagickNegateImageChannel = None
751    lib.MagickNewImage.argtypes = [c_void_p, c_int, c_int, c_void_p]
752    lib.MagickNewImage.restype = c_bool
753    lib.MagickNextImage.argtypes = [c_void_p]
754    lib.MagickNextImage.restype = c_bool
755    lib.MagickNormalizeImage.argtypes = [c_void_p]
756    lib.MagickNormalizeImage.restype = c_bool
757    if is_im_6:
758        lib.MagickNormalizeImageChannel.argtypes = [c_void_p, c_int]
759        lib.MagickNormalizeImageChannel.restype = c_bool
760    else:
761        lib.MagickNormalizeImageChannel = None
762    if is_im_6:
763        lib.MagickOilPaintImage.argtypes = [c_void_p, c_double]
764        lib.MagickOilPaintImage.restype = c_bool
765    else:
766        lib.MagickOilPaintImage.argtypes = [c_void_p, c_double, c_double]
767        lib.MagickOilPaintImage.restype = c_bool
768    lib.MagickOpaquePaintImage.argtypes = [
769        c_void_p, c_void_p, c_void_p, c_double, c_bool
770    ]
771    lib.MagickOpaquePaintImage.restype = c_bool
772    if is_im_6:
773        lib.MagickOpaquePaintImageChannel.argtypes = [
774            c_void_p, c_int, c_void_p, c_void_p, c_double, c_bool
775        ]
776        lib.MagickOpaquePaintImageChannel.restype = c_bool
777    lib.MagickOptimizeImageLayers.argtypes = [c_void_p]
778    lib.MagickOptimizeImageLayers.restype = c_void_p
779    try:
780        lib.MagickOptimizeImageTransparency.argtypes = [c_void_p]
781        lib.MagickOptimizeImageTransparency.restype = c_bool
782    except AttributeError:
783        lib.MagickOptimizeImageTransparency = None
784    if is_im_7:
785        lib.MagickOrderedDitherImage.argtypes = [c_void_p, c_char_p]
786        lib.MagickOrderedDitherImage.restype = c_bool
787    if is_im_6:
788        lib.MagickOrderedPosterizeImage.argtypes = [c_void_p, c_char_p]
789        lib.MagickOrderedPosterizeImage.restype = c_bool
790        lib.MagickOrderedPosterizeImageChannel.argtypes = [
791            c_void_p, c_int, c_char_p
792        ]
793        lib.MagickOrderedPosterizeImageChannel.restype = c_bool
794    lib.MagickPingImage.argtypes = [c_void_p, c_char_p]
795    lib.MagickPingImage.restype = c_bool
796    lib.MagickPingImageBlob.argtypes = [c_void_p, c_void_p, c_size_t]
797    lib.MagickPingImageBlob.restype = c_bool
798    lib.MagickPingImageFile.argtypes = [c_void_p, c_void_p]
799    lib.MagickPingImageFile.restype = c_bool
800    if is_im_6:
801        lib.MagickPolaroidImage.argtypes = [c_void_p, c_void_p, c_double]
802        lib.MagickPolaroidImage.restype = c_bool
803    else:
804        lib.MagickPolaroidImage.argtypes = [
805            c_void_p, c_void_p, c_char_p, c_double, c_int
806        ]
807        lib.MagickPolaroidImage.restype = c_bool
808    if IM_VERSION >= 0x708:
809        try:
810            lib.MagickPolynomialImage.argtypes = [c_void_p, c_size_t,
811                                                  POINTER(c_double)]
812            lib.MagickPolynomialImage.restype = c_bool
813        except AttributeError:
814            lib.MagickPolynomialImage = None
815    else:
816        lib.MagickPolynomialImage = None
817    lib.MagickPosterizeImage.argtypes = [c_void_p, c_size_t, c_bool]
818    lib.MagickPosterizeImage.restype = c_bool
819    lib.MagickPreviewImages.argtypes = [c_void_p, c_int]
820    lib.MagickPreviewImages.restype = c_void_p
821    lib.MagickPreviousImage.argtypes = [c_void_p]
822    lib.MagickPreviousImage.restype = c_bool
823    if IM_VERSION < 0x700:
824        lib.MagickQuantizeImage.argtypes = [
825            c_void_p, c_size_t, c_int, c_size_t, c_bool, c_bool
826        ]
827        lib.MagickQuantizeImage.restypes = c_bool
828        lib.MagickQuantizeImages.argtypes = [
829            c_void_p, c_size_t, c_int, c_size_t, c_bool, c_bool
830        ]
831        lib.MagickQuantizeImages.restype = c_bool
832    else:
833        lib.MagickQuantizeImage.argtypes = [
834            c_void_p, c_size_t, c_int, c_size_t, c_int, c_bool
835        ]
836        lib.MagickQuantizeImage.restypes = c_bool
837        lib.MagickQuantizeImages.argtypes = [
838            c_void_p, c_size_t, c_int, c_size_t, c_int, c_bool
839        ]
840        lib.MagickQuantizeImages.restype = c_bool
841    lib.MagickRaiseImage.argtypes = [
842        c_void_p, c_size_t, c_size_t, c_ssize_t, c_ssize_t, c_bool
843    ]
844    lib.MagickRandomThresholdImage.argtypes = [c_void_p, c_double, c_double]
845    lib.MagickRandomThresholdImage.restype = c_bool
846    if is_im_6:
847        lib.MagickRandomThresholdImageChannel.argtypes = [
848            c_void_p, c_int, c_double, c_double
849        ]
850        lib.MagickRandomThresholdImageChannel.restype = c_bool
851    if IM_VERSION >= 0x708:
852        try:
853            lib.MagickRangeThresholdImage.argtypes = [c_void_p, c_double,
854                                                      c_double, c_double,
855                                                      c_double]
856            lib.MagickRangeThresholdImage.restype = c_bool
857        except AttributeError:
858            lib.MagickRangeThresholdImage = None
859    else:
860        lib.MagickRangeThresholdImage = None
861    lib.MagickReadImage.argtypes = [c_void_p, c_char_p]
862    lib.MagickReadImage.restype = c_bool
863    lib.MagickReadImageBlob.argtypes = [c_void_p, c_void_p, c_size_t]
864    lib.MagickReadImageBlob.restype = c_bool
865    lib.MagickReadImageFile.argtypes = [c_void_p, c_void_p]
866    lib.MagickReadImageFile.restype = c_bool
867    try:
868        lib.MagickReduceNoiseImage.argtypes = [c_void_p, c_double]
869        lib.MagickReduceNoiseImage.restype = c_bool
870    except AttributeError:
871        pass
872    lib.MagickRemapImage.argtypes = [c_void_p, c_void_p, c_int]
873    lib.MagickRemapImage.restype = c_bool
874    lib.MagickRemoveImage.argtypes = [c_void_p]
875    lib.MagickRemoveImage.restype = c_bool
876    lib.MagickResampleImage.argtypes = [
877        c_void_p, c_double, c_double, c_int, c_double
878    ]
879    lib.MagickResampleImage.restype = c_bool
880    lib.MagickResetImagePage.argtypes = [c_void_p, c_char_p]
881    lib.MagickResetImagePage.restype = c_bool
882    lib.MagickResizeImage.argtypes = [
883        c_void_p, c_size_t, c_size_t, c_int, c_double
884    ]
885    lib.MagickResizeImage.restype = c_bool
886    lib.MagickRollImage.argtypes = [c_void_p, c_ssize_t, c_ssize_t]
887    lib.MagickRollImage.restype = c_bool
888    lib.MagickRotateImage.argtypes = [c_void_p, c_void_p, c_double]
889    lib.MagickRotateImage.restype = c_bool
890    try:
891        lib.MagickRotationalBlurImage.argtypes = [c_void_p, c_double]
892        lib.MagickRotationalBlurImage.restype = c_bool
893        if is_im_6:
894            lib.MagickRotationalBlurImageChannel.argtypes = [
895                c_void_p, c_int, c_double
896            ]
897            lib.MagickRotationalBlurImageChannel.restype = c_bool
898    except AttributeError:
899        lib.MagickRotationalBlurImage = None
900        pass
901    lib.MagickSampleImage.argtypes = [c_void_p, c_size_t, c_size_t]
902    lib.MagickSampleImage.restype = c_bool
903    lib.MagickScaleImage.argtypes = [c_void_p, c_size_t, c_size_t]
904    lib.MagickScaleImage.restype = c_bool
905    lib.MagickSegmentImage.argtypes = [
906        c_void_p, c_int, c_bool, c_double, c_double
907    ]
908    lib.MagickSegmentImage.restype = c_bool
909    lib.MagickSelectiveBlurImage.argtypes = [
910        c_void_p, c_double, c_double, c_double
911    ]
912    lib.MagickSelectiveBlurImage.restype = c_bool
913    if is_im_6:
914        lib.MagickSelectiveBlurImageChannel.argtypes = [
915            c_void_p, c_int, c_double, c_double, c_double
916        ]
917        lib.MagickSelectiveBlurImageChannel.restype = c_bool
918    lib.MagickSepiaToneImage.argtypes = [c_void_p, c_double]
919    lib.MagickSepiaToneImage.restype = c_bool
920    if is_im_6:
921        lib.MagickSeparateImage = None
922        lib.MagickSeparateImageChannel.argtypes = [c_void_p, c_int]
923        lib.MagickSeparateImageChannel.restype = c_bool
924    else:
925        lib.MagickSeparateImage.argtypes = [c_void_p, c_int]
926        lib.MagickSeparateImage.restype = c_bool
927        lib.MagickSeparateImageChannel = None
928    lib.MagickSetImage.argtypes = [c_void_p, c_void_p]
929    lib.MagickSetImage.restype = c_bool
930    lib.MagickSetImageAlphaChannel.argtypes = [c_void_p, c_int]
931    lib.MagickSetImageAlphaChannel.restype = c_bool
932    lib.MagickSetImageBackgroundColor.argtypes = [c_void_p, c_void_p]
933    lib.MagickSetImageBackgroundColor.restype = c_bool
934    if is_im_6:
935        lib.MagickSetImageBias.argtypes = [c_void_p, c_double]
936        lib.MagickSetImageBias.restype = c_bool
937    else:
938        lib.MagickSetImageBias = None
939    if is_im_6:
940        lib.MagickSetImageBluePrimary.argtypes = [
941            c_void_p, c_double, c_double
942        ]
943    else:
944        lib.MagickSetImageBluePrimary.argtypes = [
945            c_void_p, c_double, c_double, c_double
946        ]
947    lib.MagickSetImageBluePrimary.restype = c_bool
948    lib.MagickSetImageBorderColor.argtypes = [c_void_p, c_void_p]
949    lib.MagickSetImageBorderColor.restype = c_bool
950    if is_im_6:
951        lib.MagickSetImageChannelDepth.argtypes = [c_void_p, c_int, c_size_t]
952        lib.MagickSetImageClipMask.argtypes = [c_void_p, c_void_p]
953        lib.MagickSetImageClipMask.restype = c_bool
954    else:
955        lib.MagickSetImageChannelDepth = None
956        lib.MagickSetImageClipMask = None
957    if is_im_7:
958        lib.MagickSetImageChannelMask.argtypes = [c_void_p, c_int]
959        lib.MagickSetImageChannelMask.restype = c_int
960    lib.MagickSetImageColor.argtypes = [c_void_p, c_void_p]
961    lib.MagickSetImageColor.restype = c_bool
962    lib.MagickSetImageColormapColor.argtypes = [c_void_p, c_size_t, c_void_p]
963    lib.MagickSetImageColormapColor.restype = c_bool
964    lib.MagickSetImageColorspace.argtypes = [c_void_p, c_int]
965    lib.MagickSetImageColorspace.restype = c_bool
966    lib.MagickSetImageCompose.argtypes = [c_void_p, c_int]
967    lib.MagickSetImageCompose.restype = c_bool
968    lib.MagickSetImageCompression.argtypes = [c_void_p, c_int]
969    lib.MagickSetImageCompression.restype = c_bool
970    lib.MagickSetImageCompressionQuality.argtypes = [c_void_p, c_ssize_t]
971    lib.MagickSetImageCompressionQuality.restype = c_bool
972    lib.MagickSetImageDelay.argtypes = [c_void_p, c_ssize_t]
973    lib.MagickSetImageDelay.restype = c_bool
974    lib.MagickSetImageDepth.argtypes = [c_void_p]
975    lib.MagickSetImageDepth.restype = c_bool
976    lib.MagickSetImageDispose.argtypes = [c_void_p, c_int]
977    lib.MagickSetImageDispose.restype = c_bool
978    try:
979        lib.MagickSetImageEndian.argtypes = [c_void_p, c_int]
980        lib.MagickSetImageEndian.restype = c_bool
981    except AttributeError:
982        lib.MagickSetImageEndian = None
983    lib.MagickSetImageExtent.argtypes = [c_void_p, c_size_t, c_size_t]
984    lib.MagickSetImageExtent.restype = c_bool
985    lib.MagickSetImageFilename.argtypes = [c_void_p, c_char_p]
986    lib.MagickSetImageFilename.restype = c_bool
987    lib.MagickSetImageFormat.argtypes = [c_void_p, c_char_p]
988    lib.MagickSetImageFormat.restype = c_bool
989    lib.MagickSetImageFuzz.argtypes = [c_void_p, c_double]
990    lib.MagickSetImageFuzz.restype = c_bool
991    lib.MagickSetImageGamma.argtypes = [c_void_p, c_double]
992    lib.MagickSetImageGamma.restype = c_bool
993    lib.MagickSetImageGravity.argtypes = [c_void_p, c_int]
994    lib.MagickSetImageGravity.restype = c_bool
995    if is_im_6:
996        lib.MagickSetImageGreenPrimary.argtypes = [
997            c_void_p, c_double, c_double
998        ]
999    else:
1000        lib.MagickSetImageGreenPrimary.argtypes = [
1001            c_void_p, c_double, c_double, c_double
1002        ]
1003    lib.MagickSetImageGreenPrimary.restype = c_bool
1004    lib.MagickSetImageInterlaceScheme.argtypes = [c_void_p, c_int]
1005    lib.MagickSetImageInterlaceScheme.restype = c_bool
1006    lib.MagickSetImageInterpolateMethod.argtypes = [c_void_p, c_int]
1007    lib.MagickSetImageInterpolateMethod.restype = c_bool
1008    lib.MagickSetImageIterations.argtypes = [c_void_p, c_size_t]
1009    lib.MagickSetImageIterations.restype = c_bool
1010    if is_im_7:
1011        lib.MagickSetImageMask.argtypes = [c_void_p, c_int, c_void_p]
1012        lib.MagickSetImageMask.restype = c_bool
1013    else:
1014        lib.MagickSetImageMask = None
1015    lib.MagickSetImageMatte.argtypes = [c_void_p, c_bool]
1016    lib.MagickSetImageMatteColor.argtypes = [c_void_p, c_void_p]
1017    if is_im_6:
1018        lib.MagickSetImageOpacity.argtypes = [c_void_p, c_double]
1019        lib.MagickSetImageOpacity.restype = c_bool
1020    else:
1021        lib.MagickSetImageOpacity = None
1022    lib.MagickSetImageOrientation.argtypes = [c_void_p, c_int]
1023    lib.MagickSetImagePage.argtypes = [
1024        c_void_p, c_size_t, c_size_t, c_ssize_t, c_ssize_t
1025    ]
1026    lib.MagickSetImagePage.restype = c_int
1027    lib.MagickSetImageProgressMonitor.argtypes = [
1028        c_void_p, MagickProgressMonitor, c_void_p
1029    ]
1030    if is_im_6:
1031        lib.MagickSetImageRedPrimary.argtypes = [
1032            c_void_p, c_double, c_double
1033        ]
1034    else:
1035        lib.MagickSetImageRedPrimary.argtypes = [
1036            c_void_p, c_double, c_double, c_double
1037        ]
1038    lib.MagickSetImageRedPrimary.restype = c_bool
1039    lib.MagickSetImageRenderingIntent.argtypes = [c_void_p, c_int]
1040    lib.MagickSetImageRenderingIntent.restype = c_bool
1041    lib.MagickSetImageResolution.argtypes = [c_void_p, c_double, c_double]
1042    lib.MagickSetImageScene.argtypes = [c_void_p, c_size_t]
1043    lib.MagickSetImageScene.restype = c_bool
1044    lib.MagickSetImageTicksPerSecond.argtypes = [c_void_p, c_ssize_t]
1045    lib.MagickSetImageTicksPerSecond.restype = c_bool
1046    lib.MagickSetImageType.argtypes = [c_void_p, c_int]
1047    lib.MagickSetImageUnits.argtypes = [c_void_p, c_int]
1048    lib.MagickSetImageVirtualPixelMethod.argtypes = [c_void_p, c_int]
1049    if is_im_6:
1050        lib.MagickSetImageWhitePoint.argtypes = [
1051            c_void_p, c_double, c_double
1052        ]
1053    else:
1054        lib.MagickSetImageWhitePoint.argtypes = [
1055            c_void_p, c_double, c_double, c_double
1056        ]
1057    lib.MagickSetImageWhitePoint.restype = c_bool
1058    lib.MagickShadeImage.argtypes = [c_void_p, c_bool, c_double, c_double]
1059    lib.MagickShadeImage.restype = c_bool
1060    lib.MagickShadowImage.argtypes = [
1061        c_void_p, c_double, c_double, c_ssize_t, c_ssize_t
1062    ]
1063    lib.MagickShadowImage.restype = c_bool
1064    lib.MagickSharpenImage.argtypes = [c_void_p, c_double, c_double]
1065    lib.MagickSharpenImage.restype = c_bool
1066    if is_im_6:
1067        lib.MagickSharpenImageChannel.argtypes = [
1068            c_void_p, c_int, c_double, c_double
1069        ]
1070        lib.MagickSharpenImageChannel.restype = c_bool
1071    else:
1072        lib.MagickSharpenImageChannel = None
1073    lib.MagickShaveImage.argtypes = [c_void_p, c_size_t, c_size_t]
1074    lib.MagickShaveImage.restype = c_void_p
1075    lib.MagickShearImage.argtypes = [c_void_p, c_void_p, c_double, c_double]
1076    lib.MagickShearImage.restype = c_bool
1077    lib.MagickSigmoidalContrastImage.argtypes = [
1078        c_void_p, c_bool, c_double, c_double
1079    ]
1080    lib.MagickSigmoidalContrastImage.restype = c_bool
1081    if is_im_6:
1082        lib.MagickSigmoidalContrastImageChannel.argtypes = [
1083            c_void_p, c_int, c_bool, c_double, c_double
1084        ]
1085        lib.MagickSigmoidalContrastImageChannel.restype = c_bool
1086    else:
1087        lib.MagickSigmoidalContrastImageChannel = None
1088    if is_im_6:
1089        lib.MagickSimilarityImage.argtypes = [
1090            c_void_p, c_void_p, c_void_p, POINTER(c_double)
1091        ]
1092        lib.MagickSimilarityImage.restype = c_void_p
1093    else:
1094        lib.MagickSimilarityImage.argtypes = [
1095            c_void_p, c_void_p, c_int, c_double, c_void_p, POINTER(c_double)
1096        ]
1097        lib.MagickSimilarityImage.restype = c_void_p
1098    lib.MagickSketchImage.argtypes = [c_void_p, c_double, c_double, c_double]
1099    lib.MagickSketchImage.restype = c_bool
1100    lib.MagickSmushImages.argtypes = [c_void_p, c_bool, c_ssize_t]
1101    lib.MagickSmushImages.restype = c_void_p
1102    lib.MagickSolarizeImage.argtypes = [c_void_p, c_double]
1103    lib.MagickSolarizeImage.restype = c_bool
1104    try:
1105        lib.MagickSolarizeImageChannel.argtypes = [c_void_p, c_int, c_double]
1106        lib.MagickSolarizeImageChannel.restype = c_bool
1107    except AttributeError:
1108        lib.MagickSolarizeImageChannel = None
1109    if is_im_6:
1110        lib.MagickSparseColorImage.argtypes = [
1111            c_void_p, c_int, c_int, c_size_t, POINTER(c_double)
1112        ]
1113    else:
1114        lib.MagickSparseColorImage.argtypes = [
1115            c_void_p, c_int, c_size_t, POINTER(c_double)
1116        ]
1117    lib.MagickSparseColorImage.restype = c_bool
1118    lib.MagickSpliceImage.argtypes = [
1119        c_void_p, c_size_t, c_size_t, c_ssize_t, c_ssize_t
1120    ]
1121    lib.MagickSpliceImage.restype = c_bool
1122    if is_im_6:
1123        lib.MagickSpreadImage.argtypes = [c_void_p, c_double]
1124        lib.MagickSpreadImage.restype = c_bool
1125    else:
1126        lib.MagickSpreadImage.argtypes = [c_void_p, c_int, c_double]
1127        lib.MagickSpreadImage.restype = c_bool
1128    lib.MagickStatisticImage.argtypes = [c_void_p, c_int, c_size_t, c_size_t]
1129    lib.MagickStatisticImage.restype = c_bool
1130    if is_im_6:
1131        try:
1132            # TODO - Arguments for MagickStatisticImageChannel changed
1133            # around commit 2d8a006b @ Feb 9 13:02:53 2013. Use IM_VERSION
1134            # to determine correct method signature/arguments.
1135            lib.MagickStatisticImageChannel.argtypes = [
1136                c_void_p, c_int, c_int, c_size_t, c_size_t
1137            ]
1138            lib.MagickStatisticImageChannel.restype = c_bool
1139        except AttributeError:
1140            lib.MagickStatisticImageChannel = None
1141    else:
1142        lib.MagickStatisticImageChannel = None
1143    lib.MagickSteganoImage.argtypes = [c_void_p, c_void_p, c_ssize_t]
1144    lib.MagickSteganoImage.restype = c_void_p
1145    lib.MagickStereoImage.argtypes = [c_void_p, c_void_p]
1146    lib.MagickStereoImage.restype = c_void_p
1147    lib.MagickStripImage.argtypes = [c_void_p]
1148    lib.MagickStripImage.restype = c_bool
1149    if is_im_6:
1150        lib.MagickSwirlImage.argtypes = [c_void_p, c_double]
1151        lib.MagickSwirlImage.restype = c_bool
1152    else:
1153        lib.MagickSwirlImage.argtypes = [c_void_p, c_double, c_int]
1154        lib.MagickSwirlImage.restype = c_bool
1155    lib.MagickTextureImage.argtypes = [c_void_p, c_void_p]
1156    lib.MagickTextureImage.restype = c_void_p
1157    lib.MagickTintImage.argtypes = [c_void_p, c_void_p, c_void_p]
1158    lib.MagickTintImage.restype = c_bool
1159    lib.MagickThresholdImage.argtypes = [c_void_p, c_double]
1160    lib.MagickThresholdImage.restype = c_bool
1161    lib.MagickThresholdImageChannel.argtypes = [c_void_p, c_int, c_double]
1162    lib.MagickThresholdImageChannel.restype = c_bool
1163    lib.MagickThumbnailImage.argtypes = [c_void_p, c_size_t, c_size_t]
1164    lib.MagickThumbnailImage.restype = c_bool
1165    if is_im_6:
1166        lib.MagickTransformImage.argtypes = [c_void_p, c_char_p, c_char_p]
1167        lib.MagickTransformImage.restype = c_void_p
1168    else:
1169        lib.MagickTransformImage = None
1170    lib.MagickTransformImageColorspace.argtypes = [c_void_p, c_int]
1171    lib.MagickTransformImageColorspace.restype = c_bool
1172    lib.MagickTransparentPaintImage.argtypes = [
1173        c_void_p, c_void_p, c_double, c_double, c_int
1174    ]
1175    lib.MagickTransparentPaintImage.restype = c_bool
1176    lib.MagickTransposeImage.argtypes = [c_void_p]
1177    lib.MagickTransposeImage.restype = c_bool
1178    lib.MagickTransverseImage.argtypes = [c_void_p]
1179    lib.MagickTransverseImage.restype = c_bool
1180    lib.MagickTrimImage.argtypes = [c_void_p, c_double]
1181    lib.MagickTrimImage.restype = c_bool
1182    lib.MagickUniqueImageColors.argtypes = [c_void_p]
1183    lib.MagickUniqueImageColors.restype = c_bool
1184    lib.MagickUnsharpMaskImage.argtypes = [
1185        c_void_p, c_double, c_double, c_double, c_double
1186    ]
1187    lib.MagickUnsharpMaskImage.restype = c_bool
1188    if is_im_6:
1189        lib.MagickUnsharpMaskImageChannel.argtypes = [
1190            c_void_p, c_int, c_double, c_double, c_double, c_double
1191        ]
1192        lib.MagickUnsharpMaskImageChannel.restype = c_bool
1193    else:
1194        lib.MagickUnsharpMaskImageChannel = None
1195    lib.MagickVignetteImage.argtypes = [
1196        c_void_p, c_double, c_double, c_ssize_t, c_ssize_t
1197    ]
1198    lib.MagickVignetteImage.restype = c_bool
1199    if is_im_6:
1200        lib.MagickWaveImage.argtypes = [c_void_p, c_double, c_double]
1201        lib.MagickWaveImage.restype = c_bool
1202    else:
1203        lib.MagickWaveImage.argtypes = [c_void_p, c_double, c_double, c_int]
1204        lib.MagickWaveImage.restype = c_bool
1205    if IM_VERSION >= 0x708:
1206        try:
1207            lib.MagickWaveletDenoiseImage.argtypes = [c_void_p, c_double,
1208                                                      c_double]
1209            lib.MagickWaveletDenoiseImage.restype = c_bool
1210        except AttributeError:
1211            lib.MagickWaveletDenoiseImage = None
1212    else:
1213        lib.MagickWaveletDenoiseImage = None
1214    if IM_VERSION > 0x709:
1215        try:
1216            lib.MagickWhiteBalanceImage.argtypes = [c_void_p]
1217            lib.MagickWhiteBalanceImage.restype = c_bool
1218        except AttributeError:
1219            lib.MagickWhiteBalanceImage = None
1220    else:
1221        lib.MagickWhiteBalanceImage = None
1222    lib.MagickWhiteThresholdImage.argtypes = [c_void_p, c_void_p]
1223    lib.MagickWhiteThresholdImage.restype = c_bool
1224    lib.MagickWriteImage.argtypes = [c_void_p, c_char_p]
1225    lib.MagickWriteImage.restype = c_bool
1226    lib.MagickWriteImageFile.argtypes = [c_void_p, c_void_p]
1227    lib.MagickWriteImageFile.restype = c_bool
1228    lib.MagickWriteImages.argtypes = [c_void_p, c_char_p, c_int]
1229    lib.MagickWriteImages.restype = c_bool
1230    lib.MagickWriteImagesFile.argtypes = [c_void_p, c_void_p]
1231    lib.MagickWriteImagesFile.restype = c_bool
1232