Example #1
0
File: exif.go Project: quincy/exif
func (self *Data) Open(file string) error {

	cfile := C.CString(file)

	self.ed = C.exif_data_new_from_file(cfile)
	defer C.free(unsafe.Pointer(self.ed))

	C.free(unsafe.Pointer(cfile))

	if self.ed == nil {
		return fmt.Errorf("No EXIF data in file: %s\n", file)
	}

	values := C.exif_dump(self.ed)

	for true {
		value := C.pop_exif_value(values)
		if value == nil {
			break
		} else {
			self.Tags[strings.Trim(C.GoString((*value).name), " ")] = strings.Trim(C.GoString((*value).value), " ")
		}
		C.free_exif_value(value)
	}

	C.free(unsafe.Pointer(values))

	return nil
}
Example #2
0
File: exif.go Project: xiam/exif
// Open opens a file path and loads its EXIF data.
func (d *Data) Open(file string) error {

	cfile := C.CString(file)
	defer C.free(unsafe.Pointer(cfile))

	exifData := C.exif_data_new_from_file(cfile)

	if exifData == nil {
		return ErrNoExifData
	}
	defer C.exif_data_unref(exifData)

	return d.parseExifData(exifData)
}
Example #3
0
// Opens a file path and tries to read the EXIF data inside.
func (self *Data) Open(file string) error {

	cfile := C.CString(file)

	exifData := C.exif_data_new_from_file(cfile)

	C.free(unsafe.Pointer(cfile))

	if exifData == nil {
		return fmt.Errorf(ErrNoExifData.Error(), file)
	}

	defer func() {
		C.exif_data_unref(exifData)
	}()

	return self.parseExifData(exifData)
}