photoprism/internal/meta/xmp.go
Michael Mayer c978fa00f1 Backend: Proof-of-concept for indexing XMP files #68
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
2020-01-13 23:14:10 +01:00

31 lines
592 B
Go

package meta
import (
"fmt"
)
// XMP parses an XMP file and returns a Data struct.
func XMP(filename string) (data Data, err error) {
defer func() {
if e := recover(); e != nil {
data = Data{}
err = fmt.Errorf("meta: %s", e)
}
}()
doc := XmpDocument{}
if err := doc.Load(filename); err != nil {
return data, err
}
data.Title = doc.Title()
data.Artist = doc.Artist()
data.Description = doc.Description()
data.Copyright = doc.Copyright()
data.CameraMake = doc.CameraMake()
data.CameraModel = doc.CameraModel()
data.LensModel = doc.LensModel()
return data, nil
}