Skip to content

exif: Added IPTC and XMP metadata to the EXIF object #13539

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 39 additions & 4 deletions resources/images/exif/exif.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,17 @@ type ExifInfo struct {
// Image creation date/time.
Date time.Time

// A collection of the available Exif tags for this Image.
// A collection of the available Exif, Iptc and Xmp tags for this Image.
Tags Tags

// A collection of the available Exif tags for this Image.
Exif Tags

// A collection of the available Iptc tags for this Image.
Iptc Tags

// A collection of the available Xmp tags for this Image.
Xmp Tags
}

type Decoder struct {
Expand Down Expand Up @@ -193,7 +202,6 @@ func (d *Decoder) Decode(filename string, format imagemeta.ImageFormat, r io.Rea
ImageFormat: format,
ShouldHandleTag: shouldInclude,
HandleTag: handleTag,
Sources: imagemeta.EXIF, // For now. TODO(bep)
Warnf: warnf,
},
)
Expand All @@ -210,17 +218,44 @@ func (d *Decoder) Decode(filename string, format imagemeta.ImageFormat, r io.Rea
}

tags := make(map[string]any)
for k, v := range tagInfos.All() {

tagsXmp := make(map[string]any)
for k, v := range tagInfos.XMP() {
if d.shouldExclude(k) {
continue
}
if !d.shouldInclude(k) {
continue
}
tagsXmp[k] = v.Value
tags[k] = v.Value
}

tagsIptc := make(map[string]any)
for k, v := range tagInfos.IPTC() {
if d.shouldExclude(k) {
continue
}
if !d.shouldInclude(k) {
continue
}
tagsIptc[k] = v.Value
tags[k] = v.Value
}

tagsExif := make(map[string]any)
for k, v := range tagInfos.EXIF() {
if d.shouldExclude(k) {
continue
}
if !d.shouldInclude(k) {
continue
}
tagsExif[k] = v.Value
tags[k] = v.Value
}

ex = &ExifInfo{Lat: lat, Long: long, Date: tm, Tags: tags}
ex = &ExifInfo{Lat: lat, Long: long, Date: tm, Tags: tags, Exif: tagsExif, Iptc: tagsIptc, Xmp: tagsXmp}

return
}
Expand Down