Example #1
0
/*
Scale() scales the size of this image to the given dimensions.

columns: The number of columns in the scaled image.
rows: The number of rows in the scaled image
*/
func (this *Image) Scale(columns int64, rows int64) error {
	if this.magickWand == nil {
		return errors.New("error scale image:magickwand is nil")
	}

	status := C.MagickScaleImage(this.magickWand, C.ulong(columns), C.ulong(rows))
	if status == 0 {
		var etype int
		descr := C.MagickGetException(this.magickWand, (*C.ExceptionType)(unsafe.Pointer(&etype)))
		defer C.MagickRelinquishMemory(unsafe.Pointer(descr))
		return errors.New(fmt.Sprintf("error scale image: %s (ExceptionType = %d)", C.GoString(descr), etype))
	}

	return nil
}
Example #2
0
/*
Scale() scales the size of this image to the given dimensions.

columns: The number of columns in the scaled image.
rows: The number of rows in the scaled image
*/
func (this *Image) Scale(columns int64, rows int64) error {
	var err error = nil
	tran := this.Cat.NewTransaction("GraphicsMagickCmd", "Scale")
	defer func() {
		tran.SetStatus(err)
		tran.Complete()
	}()
	if this.magickWand == nil {
		err = errors.New("error scale image:magickwand is nil")
		return err
	}

	status := C.MagickScaleImage(this.magickWand, C.ulong(columns), C.ulong(rows))
	if status == 0 {
		var etype int
		descr := C.MagickGetException(this.magickWand, (*C.ExceptionType)(unsafe.Pointer(&etype)))
		defer C.MagickRelinquishMemory(unsafe.Pointer(descr))
		err = errors.New(fmt.Sprintf("error scale image: %s (ExceptionType = %d)", C.GoString(descr), etype))
		return err
	}

	return nil
}