Example #1
0
// Returns all metadata keys from the currently loaded image.
func (self *Canvas) Metadata() map[string]string {
	var n C.size_t
	var i C.size_t

	var value *C.char
	var key *C.char

	data := make(map[string]string)

	cplist := C.CString("*")

	properties := C.MagickGetImageProperties(self.wand, cplist, &n)

	C.free(unsafe.Pointer(cplist))

	for i = 0; i < n; i++ {
		key = C.MagickGetPropertyName(properties, C.size_t(i))
		value = C.MagickGetImageProperty(self.wand, key)

		data[strings.Trim(C.GoString(key), " ")] = strings.Trim(C.GoString(value), " ")

		C.MagickRelinquishMemory(unsafe.Pointer(value))
		C.MagickRelinquishMemory(unsafe.Pointer(key))
	}

	return data
}
Example #2
0
// Returns all the property names that match the specified pattern associated
// with a wand. Use GetImageProperty() to return the value of a particular
// property.
func (mw *MagickWand) GetImageProperties(pattern string) (properties []string) {
	cspattern := C.CString(pattern)
	defer C.free(unsafe.Pointer(cspattern))
	np := C.size_t(0)
	ps := C.MagickGetImageProperties(mw.mw, cspattern, &np)
	properties = sizedCStringArrayToStringSlice(ps, np)
	return
}