Exemple #1
0
// Sets the format of a particular image
func (self Canvas) SetFormat(format string) error {
	if C.MagickSetImageFormat(self.wand, C.CString(format)) != C.MagickFalse {
		return fmt.Errorf("Coluld not set format : %s", self.Error())
	}

	return nil
}
Exemple #2
0
/*
Sets the file or blob format (e.g. "BMP") to be used when a file or blob is read. Usually this is
not necessary because GraphicsMagick is able to auto-detect the format based on the file header
(or the file extension), but some formats do not use a unique header or the selection may be ambigious.
 Use MagickSetImageFormat() to set the format to be used when a file or blob is to be written.

format: The file or blob format
*/
func (this *Image) SetFormat(format string) error {
	var err error = nil
	tran := this.Cat.NewTransaction("GraphicsMagickCmd", "SetFormat")
	defer func() {
		tran.SetStatus(err)
		tran.Complete()
	}()
	if this.magickWand == nil {
		err = errors.New("error set image format:magickwand is nil")
		return err
	}

	var cs *C.char = C.CString(format)
	defer C.free(unsafe.Pointer(cs))
	status := C.MagickSetImageFormat(this.magickWand, cs)
	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 format: %s (ExceptionType = %d)", C.GoString(descr), etype))
		return err
	}

	return nil
}
Exemple #3
0
/* Sets the format of a particular image in a sequence */
func (w *MagickWand) SetImageFormat(format string) error {
	if C.MagickSetImageFormat(w.wand, C.CString(format)) == C.MagickFalse {
		eStr, eCode := w.Exception()
		return fmt.Errorf("SetImageFormat() failed : [%d] %s", eStr, eCode)
	}

	return nil
}
Exemple #4
0
// Set image format
func (self Canvas) SetFormat(format string) error {
	success := C.MagickSetImageFormat(self.wand, C.CString(format))

	if success == C.MagickFalse {
		return fmt.Errorf("Could not set compression quality: %s", self.Error())
	}

	return nil
}
Exemple #5
0
// Sets the format of a particular image
func (self *Canvas) SetFormat(format string) error {
	cformat := C.CString(format)
	defer C.free(unsafe.Pointer(cformat))

	if C.MagickSetImageFormat(self.wand, cformat) == C.MagickFalse {
		return fmt.Errorf("Could not set format: %s", self.Error())
	}

	return nil
}