Metadata: Add IPTC 2021.1 JSON/YAML Schemas incl. test files #1143 #2252

This commit is contained in:
Michael Mayer 2022-04-14 12:18:05 +02:00
parent 0096243240
commit e4999db92e
12 changed files with 5176 additions and 2 deletions

View file

@ -37,5 +37,10 @@ func showTagsAction(ctx *cli.Context) error {
fmt.Println(report.Table(rows, cols, ctx.Bool("md"))) fmt.Println(report.Table(rows, cols, ctx.Bool("md")))
// fmt.Printf("METADATA TAGS BY NAMESPACE\n")
fmt.Printf("## Metadata Tags by Namespace ##\n\n")
fmt.Println(report.Table(meta.Docs, []string{"Namespace", "Documentation"}, ctx.Bool("md")))
return nil return nil
} }

9
internal/meta/docs.go Normal file
View file

@ -0,0 +1,9 @@
package meta
var Docs = [][]string{
{"Exiftool", "https://exiftool.org/TagNames/EXIF.html"},
{"Exiftool XMP", "https://exiftool.org/TagNames/XMP.html"},
{"Adobe XMP", "https://www.adobe.com/devnet/xmp.html"},
{"Dublin Core (DCMI)", "https://www.dublincore.org/specifications/dublin-core/dcmi-terms/"},
{"IPTC Photo Metadata", "https://iptc.org/standards/photo-metadata/iptc-standard/"},
}

View file

@ -8,6 +8,62 @@ import (
) )
func TestExif(t *testing.T) { func TestExif(t *testing.T) {
t.Run("iptc-2014.jpg", func(t *testing.T) {
data, err := Exif("testdata/iptc-2014.jpg", fs.FormatJpeg, true)
if err != nil {
t.Fatal(err)
}
assert.Equal(t, "Creator1 (ref2014)", data.Artist)
assert.Equal(t, "2011-10-28T12:00:00Z", data.TakenAt.Format("2006-01-02T15:04:05Z"))
assert.Equal(t, "2011-10-28T12:00:00Z", data.TakenAtLocal.Format("2006-01-02T15:04:05Z"))
assert.Equal(t, 0, data.TakenNs)
assert.Equal(t, "The description aka caption (ref2014)", data.Description)
assert.Equal(t, "Copyright (Notice) 2014 IPTC - www.iptc.org (ref2014)", data.Copyright)
assert.Equal(t, "Adobe Photoshop CC 2014 (Windows)", data.Software)
assert.Equal(t, 1050, data.Height)
assert.Equal(t, 2100, data.Width)
assert.Equal(t, float32(0), data.Lat)
assert.Equal(t, float32(0), data.Lng)
assert.Equal(t, 0, data.Altitude)
assert.Equal(t, "", data.Exposure)
assert.Equal(t, "", data.CameraMake)
assert.Equal(t, "", data.CameraModel)
assert.Equal(t, "", data.CameraOwner)
assert.Equal(t, "", data.CameraSerial)
assert.Equal(t, 0, data.FocalLength)
assert.Equal(t, 1, data.Orientation)
})
t.Run("iptc-2016.jpg", func(t *testing.T) {
data, err := Exif("testdata/iptc-2016.jpg", fs.FormatJpeg, true)
if err != nil {
t.Fatal(err)
}
assert.Equal(t, "Creator1 (ref2016)", data.Artist)
assert.Equal(t, "2011-10-28T12:00:00Z", data.TakenAt.Format("2006-01-02T15:04:05Z"))
assert.Equal(t, "2011-10-28T12:00:00Z", data.TakenAtLocal.Format("2006-01-02T15:04:05Z"))
assert.Equal(t, 0, data.TakenNs)
assert.Equal(t, "The description aka caption (ref2016)", data.Description)
assert.Equal(t, "Copyright (Notice) 2016 IPTC - www.iptc.org (ref2016)", data.Copyright)
assert.Equal(t, "Adobe Photoshop CC 2017 (Windows)", data.Software)
assert.Equal(t, 1050, data.Height)
assert.Equal(t, 2100, data.Width)
assert.Equal(t, float32(0), data.Lat)
assert.Equal(t, float32(0), data.Lng)
assert.Equal(t, 0, data.Altitude)
assert.Equal(t, "", data.Exposure)
assert.Equal(t, "", data.CameraMake)
assert.Equal(t, "", data.CameraModel)
assert.Equal(t, "", data.CameraOwner)
assert.Equal(t, "", data.CameraSerial)
assert.Equal(t, 0, data.FocalLength)
assert.Equal(t, 1, data.Orientation)
})
t.Run("photoshop.jpg", func(t *testing.T) { t.Run("photoshop.jpg", func(t *testing.T) {
data, err := Exif("testdata/photoshop.jpg", fs.FormatJpeg, true) data, err := Exif("testdata/photoshop.jpg", fs.FormatJpeg, true)

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -10,7 +10,7 @@ import (
// Report returns form fields as table rows for reports. // Report returns form fields as table rows for reports.
func Report(f interface{}) (rows [][]string, cols []string) { func Report(f interface{}) (rows [][]string, cols []string) {
cols = []string{"Tag", "Type", "Exiftool", "XMP", "Dublin Core"} cols = []string{"Tag", "Type", "Exiftool", "Adobe XMP", "Dublin Core"}
v := reflect.ValueOf(f) v := reflect.ValueOf(f)

BIN
internal/meta/testdata/iptc-2014.jpg vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 KiB

BIN
internal/meta/testdata/iptc-2016.jpg vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 KiB

BIN
internal/meta/testdata/iptc-2017.jpg vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

BIN
internal/meta/testdata/iptc-2019.jpg vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 KiB

BIN
internal/meta/testdata/iptc-2021.jpg vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 KiB

View file

@ -9,9 +9,15 @@ import (
// Table returns a text-formatted table, optionally as valid Markdown, // Table returns a text-formatted table, optionally as valid Markdown,
// so the output can be pasted into the docs. // so the output can be pasted into the docs.
func Table(rows [][]string, cols []string, markDown bool) string { func Table(rows [][]string, cols []string, markDown bool) string {
return TableWithCaption(rows, cols, "", markDown)
}
// TableWithCaption returns a text-formatted table with caption, optionally as valid Markdown,
// so the output can be pasted into the docs.
func TableWithCaption(rows [][]string, cols []string, caption string, markDown bool) string {
buf := &bytes.Buffer{} buf := &bytes.Buffer{}
// Configure. // Set Borders.
borders := tablewriter.Border{ borders := tablewriter.Border{
Left: true, Left: true,
Right: true, Right: true,
@ -21,6 +27,12 @@ func Table(rows [][]string, cols []string, markDown bool) string {
// Render. // Render.
table := tablewriter.NewWriter(buf) table := tablewriter.NewWriter(buf)
// Set Caption.
if caption != "" {
table.SetCaption(true, caption)
}
table.SetAutoWrapText(!markDown) table.SetAutoWrapText(!markDown)
table.SetAutoFormatHeaders(false) table.SetAutoFormatHeaders(false)
table.SetHeader(cols) table.SetHeader(cols)