Skip to content

Commit

Permalink
Merge pull request #4 from martinhoefling/digikam
Browse files Browse the repository at this point in the history
Add digikam model, closes #3
  • Loading branch information
echa authored Dec 16, 2018
2 parents ebdb369 + 66199b7 commit 4f6a2fb
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 0 deletions.
27 changes: 27 additions & 0 deletions models/digikam/enum.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// from http://www.exiv2.org/tags-xmp-digiKam.html

package digikam

type ColorLabel string

const (
NoColorLabel ColorLabel = "0"
LabelRed ColorLabel = "1"
LabelOrange ColorLabel = "2"
LabelYellow ColorLabel = "3"
LabelGreen ColorLabel = "4"
LabelBlue ColorLabel = "5"
LabelMagenta ColorLabel = "6"
LabelGray ColorLabel = "7"
LabelBlack ColorLabel = "8"
LabelWhite ColorLabel = "9"
)

type PickLabel string

const (
NoPickLabel PickLabel = "0"
ItemRejected PickLabel = "1"
ItemPendingValidation = "2"
ItemAccepted = "3"
)
87 changes: 87 additions & 0 deletions models/digikam/model.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// from http://www.exiv2.org/tags-xmp-digiKam.html

package digikam

import (
"fmt"
"trimmer.io/go-xmp/xmp"
)

var (
NsDk = xmp.NewNamespace("digiKam", "http://www.digikam.org/ns/1.0/", NewModel)
)

func init() {
xmp.Register(NsDk, xmp.XmpMetadata)
}

func NewModel(name string) xmp.Model {
return &Digikam{}
}

func MakeModel(d *xmp.Document) (*Digikam, error) {
m, err := d.MakeModel(NsDk)
if err != nil {
return nil, err
}
x, _ := m.(*Digikam)
return x, nil
}

func FindModel(d *xmp.Document) *Digikam {
if m := d.FindModel(NsDk); m != nil {
return m.(*Digikam)
}
return nil
}

type Digikam struct {
TagsList xmp.StringList `xmp:"digiKam:TagsList"`
CaptionsAutorNames xmp.AltString `xmp:"digiKam:CaptionsAutorNames"`
CaptionsDateTimeStamps xmp.AltString `xmp:"digiKam:CaptionsDateTimeStamps"`
ImageHistory string `xmp:"digiKam:ImageHistory"`
ImageUniqueID string `xmp:"digiKam:ImageUniqueID"`
LensCorrectionSettings string `xmp:"digiKam:LensCorrectionSettings"`
ColorLabel ColorLabel `xmp:"digiKam:ColorLabel"`
PickLabel PickLabel `xmp:"digiKam:PickLabel"`
}

func (x Digikam) Can(nsName string) bool {
return NsDk.GetName() == nsName
}

func (x Digikam) Namespaces() xmp.NamespaceList {
return xmp.NamespaceList{NsDk}
}

func (x *Digikam) SyncModel(d *xmp.Document) error {
return nil
}

func (x *Digikam) SyncFromXMP(d *xmp.Document) error {
return nil
}

func (x Digikam) SyncToXMP(d *xmp.Document) error {
return nil
}

func (x *Digikam) CanTag(tag string) bool {
_, err := xmp.GetNativeField(x, tag)
return err == nil
}

func (x *Digikam) GetTag(tag string) (string, error) {
if v, err := xmp.GetNativeField(x, tag); err != nil {
return "", fmt.Errorf("%s: %v", NsDk.GetName(), err)
} else {
return v, nil
}
}

func (x *Digikam) SetTag(tag, value string) error {
if err := xmp.SetNativeField(x, tag, value); err != nil {
return fmt.Errorf("%s: %v", NsDk.GetName(), err)
}
return nil
}
19 changes: 19 additions & 0 deletions samples/digikam_sample.jpg.xmp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="XMP Core 4.4.0-Exiv2">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about=""
xmlns:digiKam="http://www.digikam.org/ns/1.0/"
digiKam:PickLabel="2"
digiKam:ColorLabel="4"
digiKam:ImageHistory="&lt;?xml version=&quot;1.0&quot;?&gt;&#xA;&lt;history version=&quot;1&quot;&gt;&#xA; &lt;file uuid=&quot;287a11cb7f4ce35445751bdc4399d95a6407997b46dde6a24c2669ee49bd5e29&quot; type=&quot;original&quot;&gt;&#xA; &lt;fileParams fileName=&quot;18-12-07 14-32-27 3223.jpg&quot; filePath=&quot;/Users/martin/Documents/Bilder/Linked/000-toimport/&quot; fileHash=&quot;6407997b46dde6a24c2669ee49bd5e29&quot; fileSize=&quot;2094669&quot; creationDate=&quot;2018-12-07T14:32:28&quot;/&gt;&#xA; &lt;/file&gt;&#xA; &lt;filter filterName=&quot;digikam:ColorFXFilter&quot; filterDisplayName=&quot;Color FX Filter&quot; filterVersion=&quot;1&quot; filterCategory=&quot;reproducible&quot; branch=&quot;true&quot;&gt;&#xA; &lt;params&gt;&#xA; &lt;param name=&quot;intensity&quot; value=&quot;100&quot;/&gt;&#xA; &lt;param name=&quot;iteration&quot; value=&quot;2&quot;/&gt;&#xA; &lt;param name=&quot;level&quot; value=&quot;29&quot;/&gt;&#xA; &lt;param name=&quot;path&quot; value=&quot;/opt/digikam/Applications/KF5/digikam.app/Contents/Resources//digikam/data/lut3d/bleach.png&quot;/&gt;&#xA; &lt;param name=&quot;type&quot; value=&quot;0&quot;/&gt;&#xA; &lt;/params&gt;&#xA; &lt;/filter&gt;&#xA;&lt;/history&gt;&#xA;"
digiKam:ImageUniqueID="3f6857dc97b8f8ba06cee65532b532576407997b46dde6a24c2669ee49bd5e29">
<digiKam:TagsList>
<rdf:Seq>
<rdf:li>Steine</rdf:li>
<rdf:li>Leuchtturm</rdf:li>
</rdf:Seq>
</digiKam:TagsList>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>
<?xpacket end="w"?>

0 comments on commit 4f6a2fb

Please sign in to comment.