// Reads an image or image sequence from a blob. func (self Canvas) OpenBlob(blob []byte, length uint) error { status := C.MagickReadImageBlob(self.wand, unsafe.Pointer(&blob[0]), C.size_t(length)) if status == C.MagickFalse { return fmt.Errorf(`Could not open image from blob: %s`, self.Error()) } return nil }
/* Reads an image or image sequence from a blob. */ func (w *MagickWand) ReadImageBlob(blob []byte, length uint) error { if C.MagickReadImageBlob(w.wand, unsafe.Pointer(&blob[0]), C.size_t(length)) == C.MagickFalse { eStr, eCode := w.Exception() return fmt.Errorf("ReadImageBlob() failed : [%d] %s", eStr, eCode) } return nil }
// Opens an image from binary, returns true on success. func (cv Canvas) OpenBlob(data []byte) bool { cv.filename = "" status := C.MagickReadImageBlob(cv.wand, unsafe.Pointer(&data[0]), C.size_t(len(data))) if status == C.MagickFalse { return false } return true }
func Open(filename string) (img *Image, err error) { img = &Image{wand: C.NewMagickWand()} var file *os.File if file, err = os.Open(filename); err != nil { return nil, err } var data []byte if data, err = ioutil.ReadAll(file); err != nil { return nil, err } C.MagickReadImageBlob(img.wand, unsafe.Pointer(&data[0]), C.size_t(len(data))) return img, nil }
// Public: read a blob data into the current wand // // Examples: // im = NewMage() // original, err := ioutil.ReadFile("test.jpg") // success := im.ReadBlob(original) func (m *Mage) ReadBlob(blob []byte) bool { return mBoolean(C.MagickReadImageBlob( m.wand, unsafe.Pointer(&blob[0]), C.size_t(len(blob)))) }