go-exiftool is a golang library that wraps ExifTool.
ExifTool's purpose is to extract and update as much metadata as possible (EXIF, IPTC, XMP, GPS, ...) from a lots of differents file types (Office documents, pictures, movies, PDF, ...).
go-exiftool uses ExifTool's stay_open
feature to optimize performance.
go-exiftool needs ExifTool to be installed.
sudo apt-get install exiftool
By default, go-exiftool
binary will look for exiftool
binary in $PATH, but another location can be specified (see SetExiftoolBinaryPath
functional option).
et, err := exiftool.NewExiftool()
if err != nil {
fmt.Printf("Error when intializing: %v\n", err)
return
}
defer et.Close()
fileInfos := et.ExtractMetadata("testdata/20190404_131804.jpg")
for _, fileInfo := range fileInfos {
if fileInfo.Err != nil {
fmt.Printf("Error concerning %v: %v\n", fileInfo.File, fileInfo.Err)
continue
}
for k, v := range fileInfo.Fields {
fmt.Printf("[%v] %v\n", k, v)
}
}
Output :
[FOV] 69.4 deg
[Orientation] Rotate 90 CW
[ColorSpace] sRGB
[Compression] JPEG (old-style)
[YCbCrSubSampling] YCbCr4:2:2 (2 1)
[Aperture] 1.7
[ColorComponents] 3
[SubSecCreateDate] 2019:04:04 13:18:03.0937
[FileSize] 26 kB
[FileAccessDate] 2019:05:17 22:44:26+02:00
[DateTimeOriginal] 2019:04:04 13:18:03
[CreateDate] 2019:04:04 13:18:03
(...)
See example function ExampleExiftool_Write in exiftool_sample_test.go
-charset
parameter (thank to @PROger4ever)go-exiftool
when a folder was provided. Folder metadata extraction will now return a new sentinel error (ErrNotFile).ErrBufferTooSmall
) that is returned when go-exiftool
's buffer isn't big enough for a specifi file (countermeasure: initialize go-exiftool
with the Buffer
option)DateFormat
) (thanks to Andy Gorman)CoordFormat
) (thanks to Andy Gorman)