Exemple #1
0
// Returns a value associated with the specified property.
func (mw *MagickWand) GetImageProperty(property string) string {
	csproperty := C.CString(property)
	defer C.free(unsafe.Pointer(csproperty))
	cspv := C.MagickGetImageProperty(mw.mw, csproperty)
	defer C.free(unsafe.Pointer(cspv))
	return C.GoString(cspv)
}
Exemple #2
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
}