Ejemplo n.º 1
0
/*
Sets the image quality factor, which determines compression options when saving the file

quality: The image quality
*/
func (this *Image) SetCompressionQuality(quality int) error {
	if this.magickWand == nil {
		return errors.New("error set image compression quality:magickwand is nil")
	}

	status := C.MagickSetCompressionQuality(this.magickWand, C.ulong(quality))
	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 set image compression quality: %s (ExceptionType = %d)", C.GoString(descr), etype))
	}

	return nil
}
Ejemplo n.º 2
0
/*
Sets the image quality factor, which determines compression options when saving the file

quality: The image quality
*/
func (this *Image) SetCompressionQuality(quality int) error {
	var err error = nil
	tran := this.Cat.NewTransaction("GraphicsMagickCmd", "SetCompressionQuality")
	defer func() {
		tran.SetStatus(err)
		tran.Complete()
	}()
	if this.magickWand == nil {
		err = errors.New("error set image compression quality:magickwand is nil")
		return err
	}

	status := C.MagickSetCompressionQuality(this.magickWand, C.ulong(quality))
	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 set image compression quality: %s (ExceptionType = %d)", C.GoString(descr), etype))
		return err
	}

	return nil
}
Ejemplo n.º 3
0
// Sets the wand compression quality.
func (mw *MagickWand) SetCompressionQuality(quality uint) error {
	C.MagickSetCompressionQuality(mw.mw, C.size_t(quality))
	return mw.GetLastError()
}
Ejemplo n.º 4
0
// Sets the wand compression quality.
func (mw *MagickWand) SetCompressionQuality(quality uint) error {
	ok := C.MagickSetCompressionQuality(mw.mw, C.size_t(quality))
	return mw.getLastErrorIfFailed(ok)
}