Expose provides a Go package and command tool for extracting and parsing XMP, EXIF and IPTC metadata from image and video files using the exiv2 binary tool. The output data is grouped by type in JSON format.
This example was created for the Feb 2017 GoLangPhilly meetup presentation on Processing Image and Video Metadata by Rob Murtha.
This package requires the exiv2 binary (see instructions below). exiv2 website exiv2 download / source
go get github.com/robmurtha/expose
Usage: expose [-flags] filename
flags:
-p pretty JSON
-v verbose logging
This project includes a main.go for running from the command line and extracting all possible information. An exiv2 parsing package is included and can be used independently.
// parse XMP tags
// with output from exiv2 -PXgnycv filename (see main)
expose := exiv2.New(output)
fields, _ := expose.Fields()
jsonBytes, _ := json.Marshal(fields)
brew install exiv2
The default brew version has video support disabled, if you need video support follow these instructions.
wget http://exiv2.org/exiv2-0.25.tar.gz
tar -xzf exiv2-0.25.tar.gz
cd exiv2-0.25
brew install exiv2 --only-dependencies
./configure --enable-video
make install
apt-get install exiv2
The JSON records are organized by metadata type as arrays of Field. Organization by group, type and additional parsing of values is up to the user.
{
"expose": {
"xmp": [
{
"group": "video",
"name": "FileSize",
"type": "XmpText",
"count": 9,
"value": "0.0515432"
},
{
"group": "video",
"name": "FileName",
"type": "XmpText",
"count": 27,
"value": "testdata/samsung_galaxy.mp4"
},
{
"group": "video",
"name": "MimeType",
"type": "XmpText",
"count": 15,
"value": "video/quicktime"
...