func (mw *MagickWand) HaldClutImage(hald *MagickWand) error {
	ok := C.MagickHaldClutImage(mw.mw, hald.mw)
	return mw.getLastErrorIfFailed(ok)
}
Replaces colors in the image from a Hald color lookup table. A Hald color
lookup table is a 3-dimensional color cube mapped to 2 dimensions. Create
it with the HALD coder. You can apply any color transformation to the Hald
image and then use this method to apply the transform to the image.
package gmagick
import "C"
import (
	"errors"
	"os"
	"runtime"
	"sync"
	"sync/atomic"
	"syscall"
	"unsafe"
)
type MagickWand struct {
	mw   *C.MagickWand
	init sync.Once
}
func newMagickWand(cmw *C.MagickWand) *MagickWand {
	mw := &MagickWand{mw: cmw}
	runtime.SetFinalizer(mw, Destroy)
	mw.IncreaseCount()
	return mw
}
func NewMagickWand() *MagickWand {
	return newMagickWand(C.NewMagickWand())
}
func (mw *MagickWand) Clone() *MagickWand {
	return newMagickWand(C.CloneMagickWand(mw.mw))
}
func (mw *MagickWand) Destroy() {
	if mw.mw == nil {
		return
	}
	mw.init.Do(func() {
		C.DestroyMagickWand(mw.mw)
		mw.mw = nil
		mw.DecreaseCount()
	})
}
func (mw *MagickWand) IncreaseCount() {
	atomic.AddInt64(&magickWandCounter, int64(1))
	unsetCanTerminate()
}
func (mw *MagickWand) DecreaseCount() {
	atomic.AddInt64(&magickWandCounter, int64(-1))
	setCanTerminate()
}
func (mw *MagickWand) GetImageIndex() uint {
	return uint(C.MagickGetImageIndex(mw.mw))
}
func (mw *MagickWand) AdaptiveThresholdImage(width, height uint, offset int) error {
	ok := C.MagickAdaptiveThresholdImage(mw.mw, C.ulong(width), C.ulong(height), C.long(offset))
	return mw.getLastErrorIfFailed(ok)
}
func (mw *MagickWand) AddImage(wand *MagickWand) error {
	ok := C.MagickAddImage(mw.mw, wand.mw)
	return mw.getLastErrorIfFailed(ok)
}
func (mw *MagickWand) AddNoiseImage(noiseType NoiseType) error {
	ok := C.MagickAddNoiseImage(mw.mw, C.NoiseType(noiseType))
	return mw.getLastErrorIfFailed(ok)
}
func (mw *MagickWand) AffineTransformImage(drawingWand *DrawingWand) error {
	ok := C.MagickAffineTransformImage(mw.mw, drawingWand.dw)
	return mw.getLastErrorIfFailed(ok)
}
func (mw *MagickWand) AnimateImages(server string) error {
	csserver := C.CString(server)
	defer C.free(unsafe.Pointer(csserver))
	ok := C.MagickAnimateImages(mw.mw, csserver)
	return mw.getLastErrorIfFailed(ok)
}
func (mw *MagickWand) AnnotateImage(drawingWand *DrawingWand, x, y, angle float64, text string) error {
	cstext := C.CString(text)
	defer C.free(unsafe.Pointer(cstext))
	ok := C.MagickAnnotateImage(mw.mw, drawingWand.dw, C.double(x), C.double(y), C.double(angle), cstext)
	return mw.getLastErrorIfFailed(ok)
}
func (mw *MagickWand) AppendImages(topToBottom bool) *MagickWand {
	return newMagickWand(C.MagickAppendImages(mw.mw, b2i(topToBottom)))
}
func (mw *MagickWand) AverageImages() *MagickWand {
	return newMagickWand(C.MagickAverageImages(mw.mw))
}
func (mw *MagickWand) BlackThresholdImage(threshold *PixelWand) error {
	ok := C.MagickBlackThresholdImage(mw.mw, threshold.pw)
	return mw.getLastErrorIfFailed(ok)
}
func (mw *MagickWand) BlurImage(radius, sigma float64) error {
	ok := C.MagickBlurImage(mw.mw, C.double(radius), C.double(sigma))
	return mw.getLastErrorIfFailed(ok)
}
func (mw *MagickWand) BorderImage(borderColor *PixelWand, width, height uint) error {
	ok := C.MagickBorderImage(mw.mw, borderColor.pw, C.ulong(width), C.ulong(height))
	return mw.getLastErrorIfFailed(ok)
}
func (mw *MagickWand) CharcoalImage(radius, sigma float64) error {
	ok := C.MagickCharcoalImage(mw.mw, C.double(radius), C.double(sigma))
	return mw.getLastErrorIfFailed(ok)
}
func (mw *MagickWand) ChopImage(width, height uint, x, y int) error {
	ok := C.MagickChopImage(mw.mw, C.ulong(width), C.ulong(height), C.long(x), C.long(y))
	return mw.getLastErrorIfFailed(ok)
}
func (mw *MagickWand) ClipImage() error {
	ok := C.MagickClipImage(mw.mw)
	return mw.getLastErrorIfFailed(ok)
}
func (mw *MagickWand) CoalesceImages() *MagickWand {
	return newMagickWand(C.MagickCoalesceImages(mw.mw))
}
func (mw *MagickWand) ColorizeImage(colorize, opacity *PixelWand) error {
	ok := C.MagickColorizeImage(mw.mw, colorize.pw, opacity.pw)
	return mw.getLastErrorIfFailed(ok)
}
func (mw *MagickWand) CommentImage(comment string) error {
	cscomment := C.CString(comment)
	defer C.free(unsafe.Pointer(cscomment))
	ok := C.MagickCommentImage(mw.mw, cscomment)
	return mw.getLastErrorIfFailed(ok)
}
func (mw *MagickWand) CompareImageChannels(reference *MagickWand, channel ChannelType, metric MetricType) (wand *MagickWand, distortion float64) {
	cmw := C.MagickCompareImageChannels(mw.mw, reference.mw, C.ChannelType(channel), C.MetricType(metric), (*C.double)(&distortion))
	wand = newMagickWand(cmw)
	return
}
func (mw *MagickWand) CompareImages(reference *MagickWand, metric MetricType) (wand *MagickWand, distortion float64) {
	cmw := C.MagickCompareImages(mw.mw, reference.mw, C.MetricType(metric), (*C.double)(&distortion))
	wand = newMagickWand(cmw)
	return
}
func (mw *MagickWand) CompositeImage(source *MagickWand, compose CompositeOperator, x, y int) error {
	ok := C.MagickCompositeImage(mw.mw, source.mw, C.CompositeOperator(compose), C.long(x), C.long(y))
	return mw.getLastErrorIfFailed(ok)
}
func (mw *MagickWand) ContrastImage(sharpen bool) error {
	ok := C.MagickContrastImage(mw.mw, b2i(sharpen))
	return mw.getLastErrorIfFailed(ok)
}
func (mw *MagickWand) ConvolveImage(order uint, kernel []float64) error {
	ok := C.MagickConvolveImage(mw.mw, C.ulong(order), (*C.double)(&kernel[0]))
	return mw.getLastErrorIfFailed(ok)
}
func (mw *MagickWand) CropImage(width, height uint, x, y int) error {
	ok := C.MagickCropImage(mw.mw, C.ulong(width), C.ulong(height), C.long(x), C.long(y))
	return mw.getLastErrorIfFailed(ok)
}
func (mw *MagickWand) CycleColormapImage(displace int) error {
	ok := C.MagickCycleColormapImage(mw.mw, C.long(displace))
	return mw.getLastErrorIfFailed(ok)
}
func (mw *MagickWand) DeconstructImages() *MagickWand {
	return newMagickWand(C.MagickDeconstructImages(mw.mw))
}
func (mw *MagickWand) DescribeImage() string {
	description := C.MagickDescribeImage(mw.mw)
	defer C.MagickRelinquishMemory(unsafe.Pointer(description))
	return C.GoString(description)
}
func (mw *MagickWand) DespeckleImage() error {
	ok := C.MagickDespeckleImage(mw.mw)
	return mw.getLastErrorIfFailed(ok)
}
func (mw *MagickWand) DisplayImage(server string) error {
	cstring := C.CString(server)
	defer C.free(unsafe.Pointer(cstring))
	ok := C.MagickDisplayImage(mw.mw, cstring)
	return mw.getLastErrorIfFailed(ok)
}
func (mw *MagickWand) DisplayImages(server string) error {
	cstring := C.CString(server)
	defer C.free(unsafe.Pointer(cstring))
	ok := C.MagickDisplayImages(mw.mw, cstring)
	return mw.getLastErrorIfFailed(ok)
}
func (mw *MagickWand) DrawImage(dw *DrawingWand) error {
	ok := C.MagickDrawImage(mw.mw, dw.dw)
	return mw.getLastErrorIfFailed(ok)
}
func (mw *MagickWand) EdgeImage(radius float64) error {
	ok := C.MagickEdgeImage(mw.mw, C.double(radius))
	return mw.getLastErrorIfFailed(ok)
}
func (mw *MagickWand) EmbossImage(radius, sigma float64) error {
	ok := C.MagickEmbossImage(mw.mw, C.double(radius), C.double(sigma))
	return mw.getLastErrorIfFailed(ok)
}
func (mw *MagickWand) EnhanceImage() error {
	ok := C.MagickEnhanceImage(mw.mw)
	return mw.getLastErrorIfFailed(ok)
}
func (mw *MagickWand) EqualizeImage() error {
	ok := C.MagickEqualizeImage(mw.mw)
	return mw.getLastErrorIfFailed(ok)
}
func (mw *MagickWand) ExtentImage(width, height uint, x, y int) error {
	ok := C.MagickExtentImage(mw.mw, C.size_t(width), C.size_t(height), C.ssize_t(x), C.ssize_t(y))
	return mw.getLastErrorIfFailed(ok)
}
func (mw *MagickWand) FlipImage() error {
	ok := C.MagickFlipImage(mw.mw)
	return mw.getLastErrorIfFailed(ok)
}
func (mw *MagickWand) FlopImage() error {
	ok := C.MagickFlopImage(mw.mw)
	return mw.getLastErrorIfFailed(ok)
}
func (mw *MagickWand) FrameImage(matteColor *PixelWand, width, height uint, innerBevel, outerBevel int) error {
	ok := C.MagickFrameImage(mw.mw, matteColor.pw, C.ulong(width), C.ulong(height), C.long(innerBevel), C.long(outerBevel))
	return mw.getLastErrorIfFailed(ok)
}
func (mw *MagickWand) FxImage(expression string) (fxmw *MagickWand, err error) {
	csexpression := C.CString(expression)
	defer C.free(unsafe.Pointer(csexpression))
	fxmw = newMagickWand(C.MagickFxImage(mw.mw, csexpression))
	err = mw.GetLastError()
	return
}
func (mw *MagickWand) FxImageChannel(channel ChannelType, expression string) *MagickWand {
	csexpression := C.CString(expression)
	defer C.free(unsafe.Pointer(csexpression))
	return newMagickWand(C.MagickFxImageChannel(mw.mw, C.ChannelType(channel), csexpression))
}
func (mw *MagickWand) GammaImage(gamma float64) error {
	ok := C.MagickGammaImage(mw.mw, C.double(gamma))
	return mw.getLastErrorIfFailed(ok)
}
func (mw *MagickWand) GammaImageChannel(channel ChannelType, gamma float64) error {
	ok := C.MagickGammaImageChannel(mw.mw, C.ChannelType(channel), C.double(gamma))
	return mw.getLastErrorIfFailed(ok)
}
func (mw *MagickWand) GetFilename() string {
	p := C.MagickGetFilename(mw.mw)
	defer C.MagickRelinquishMemory(unsafe.Pointer(p))
	return C.GoString(p)
}
func (mw *MagickWand) GetImageAttribute(attributeName string) string {
	n := C.CString(attributeName)
	defer C.free(unsafe.Pointer(n))
	p := C.MagickGetImageAttribute(mw.mw, n)
	defer C.MagickRelinquishMemory(unsafe.Pointer(p))
	return C.GoString(p)
}
func (mw *MagickWand) GetImageBackgroundColor() (bgColor *PixelWand, err error) {
	cbgcolor := NewPixelWand()
	ok := C.MagickGetImageBackgroundColor(mw.mw, cbgcolor.pw)
	return cbgcolor, mw.getLastErrorIfFailed(ok)
}
func (mw *MagickWand) GetImageBluePrimary() (x, y float64, err error) {
	ok := C.MagickGetImageBluePrimary(mw.mw, (*C.double)(&x), (*C.double)(&y))
	err = mw.getLastErrorIfFailed(ok)
	return
}
func (mw *MagickWand) GetImageBorderColor() (borderColor *PixelWand, err error) {
	cbc := NewPixelWand()
	ok := C.MagickGetImageBorderColor(mw.mw, cbc.pw)
	return cbc, mw.getLastErrorIfFailed(ok)
}
func (mw *MagickWand) GetImageChannelDepth(channel ChannelType) uint {
	return uint(C.MagickGetImageChannelDepth(mw.mw, C.ChannelType(channel)))
}
func (mw *MagickWand) GetImageChannelMean(channel ChannelType) (mean, stdev float64, err error) {
	ok := C.MagickGetImageChannelMean(mw.mw, C.ChannelType(channel), (*C.double)(&mean), (*C.double)(&stdev))
	err = mw.getLastErrorIfFailed(ok)
	return
}
func (mw *MagickWand) GetImageColormapColor(index uint) (color *PixelWand, err error) {
	cpw := NewPixelWand()
	ok := C.MagickGetImageColormapColor(mw.mw, C.ulong(index), cpw.pw)
	return cpw, mw.getLastErrorIfFailed(ok)
}
func (mw *MagickWand) GetImageColors() uint {
	return uint(C.MagickGetImageColors(mw.mw))
}
func (mw *MagickWand) GetImageColorspace() ColorspaceType {
	return ColorspaceType(C.MagickGetImageColorspace(mw.mw))
}
func (mw *MagickWand) GetImageCompose() CompositeOperator {
	return CompositeOperator(C.MagickGetImageCompose(mw.mw))
}
func (mw *MagickWand) GetImageCompression() CompressionType {
	return CompressionType(C.MagickGetImageCompression(mw.mw))
}
func (mw *MagickWand) GetImageDelay() uint {
	return uint(C.MagickGetImageDelay(mw.mw))
}
func (mw *MagickWand) GetImageDepth() uint {
	return uint(C.MagickGetImageDepth(mw.mw))
}
func (mw *MagickWand) GetImageDispose() DisposeType {
	return DisposeType(C.MagickGetImageDispose(mw.mw))
}
func (mw *MagickWand) GetImageFilename() string {
	p := C.MagickGetImageFilename(mw.mw)
	defer C.MagickRelinquishMemory(unsafe.Pointer(p))
	return C.GoString(p)
}
func (mw *MagickWand) GetImageFormat() string {
	p := C.MagickGetImageFormat(mw.mw)
	defer C.MagickRelinquishMemory(unsafe.Pointer(p))
	return C.GoString(p)
}
func (mw *MagickWand) GetImageFuzz() float64 {
	return float64(C.MagickGetImageFuzz(mw.mw))
}
func (mw *MagickWand) GetImageGamma() float64 {
	return float64(C.MagickGetImageGamma(mw.mw))
}
func (mw *MagickWand) MagickGetImageGeometry() string {
	p := C.MagickGetImageGeometry(mw.mw)
	if p != nil {
		defer C.MagickRelinquishMemory(unsafe.Pointer(p))
		return C.GoString(p)
	}
	return ""
}
func (mw *MagickWand) GetImageGravity() GravityType {
	return GravityType(C.MagickGetImageGravity(mw.mw))
}
func (mw *MagickWand) GetImage() *MagickWand {
	return newMagickWand(C.MagickGetImage(mw.mw))
}
func (mw *MagickWand) GetImageGreenPrimary() (x, y float64, err error) {
	ok := C.MagickGetImageGreenPrimary(mw.mw, (*C.double)(&x), (*C.double)(&y))
	err = mw.getLastErrorIfFailed(ok)
	return
}
func (mw *MagickWand) GetImageHeight() uint {
	return uint(C.MagickGetImageHeight(mw.mw))
}
func (mw *MagickWand) GetImageHistogram() (numberColors uint, pws []PixelWand) {
	cnc := C.ulong(0)
	p := C.MagickGetImageHistogram(mw.mw, &cnc)
	defer C.MagickRelinquishMemory(unsafe.Pointer(p))
	q := uintptr(unsafe.Pointer(p))
	for {
		p = (**C.PixelWand)(unsafe.Pointer(q))
		if *p == nil {
			break
		}
		pws = append(pws, *newPixelWand(*p))
		q += unsafe.Sizeof(q)
	}
	numberColors = uint(cnc)
	return
}
func (mw *MagickWand) GetImageInterlaceScheme() InterlaceType {
	return InterlaceType(C.MagickGetImageInterlaceScheme(mw.mw))
}
func (mw *MagickWand) GetImageIterations() uint {
	return uint(C.MagickGetImageIterations(mw.mw))
}
func (mw *MagickWand) GetImageMatteColor() (matteColor *PixelWand, err error) {
	cptrpw := NewPixelWand()
	ok := C.MagickGetImageMatteColor(mw.mw, cptrpw.pw)
	return cptrpw, mw.getLastErrorIfFailed(ok)
}
func (mw *MagickWand) GetImagePage() (w, h uint, x, y int, err error) {
	var cw, ch C.ulong
	var cx, cy C.long
	ok := C.MagickGetImagePage(mw.mw, &cw, &ch, &cx, &cy)
	return uint(cw), uint(ch), int(cx), int(cy), mw.getLastErrorIfFailed(ok)
}
func (mw *MagickWand) GetImageRedPrimary() (x, y float64, err error) {
	var cdx, cdy C.double
	ok := C.MagickGetImageRedPrimary(mw.mw, &cdx, &cdy)
	return float64(cdx), float64(cdy), mw.getLastErrorIfFailed(ok)
}
func (mw *MagickWand) GetImageResolution() (x, y float64, err error) {
	var dx, dy C.double
	ok := C.MagickGetImageResolution(mw.mw, &dx, &dy)
	return float64(dx), float64(dy), mw.getLastErrorIfFailed(ok)
}
func (mw *MagickWand) GetImageSavedType() ImageType {
	return ImageType(C.MagickGetImageSavedType(mw.mw))
}
func (mw *MagickWand) GetImageSignature() string {
	p := C.MagickGetImageSignature(mw.mw)
	defer C.MagickRelinquishMemory(unsafe.Pointer(p))
	return C.GoString(p)
}
func (mw *MagickWand) GetImageType() ImageType {
	return ImageType(C.MagickGetImageType(mw.mw))
}
func (mw *MagickWand) GetImageUnits() ResolutionType {
	return ResolutionType(C.MagickGetImageUnits(mw.mw))
}
func (mw *MagickWand) GetImageWhitePoint() (x, y float64, err error) {
	ok := C.MagickGetImageWhitePoint(mw.mw, (*C.double)(&x), (*C.double)(&y))
	err = mw.getLastErrorIfFailed(ok)
	return
}
func (mw *MagickWand) GetImageWidth() uint {
	return uint(C.MagickGetImageWidth(mw.mw))
}
func (mw *MagickWand) GetNumberImages() uint {
	return uint(C.MagickGetNumberImages(mw.mw))
}
func (mw *MagickWand) GetSamplingFactors() (factors []float64) {
	num := C.ulong(0)
	pd := C.MagickGetSamplingFactors(mw.mw, &num)
	defer C.MagickRelinquishMemory(unsafe.Pointer(pd))
	factors = sizedDoubleArrayToFloat64Slice(pd, num)
	return
}
func (mw *MagickWand) GetSize() (uint, uint, error) {
	w := C.ulong(0)
	h := C.ulong(0)
	ok := C.MagickGetSize(mw.mw, &w, &h)
	return uint(w), uint(h), mw.getLastErrorIfFailed(ok)
}