2020-05-13 20:53:15 +02:00
|
|
|
package meta
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2021-07-13 17:56:26 +02:00
|
|
|
"time"
|
2020-05-13 20:53:15 +02:00
|
|
|
|
2020-12-25 20:29:06 +01:00
|
|
|
"github.com/photoprism/photoprism/pkg/fs"
|
|
|
|
|
2020-05-13 20:53:15 +02:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestJSON(t *testing.T) {
|
2020-05-15 09:39:32 +02:00
|
|
|
t.Run("iphone-mov.json", func(t *testing.T) {
|
2020-06-04 14:56:27 +02:00
|
|
|
data, err := JSON("testdata/iphone-mov.json", "")
|
2020-05-15 09:39:32 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.Logf("DATA: %+v", data)
|
|
|
|
|
2022-01-06 09:55:41 +01:00
|
|
|
assert.Equal(t, "20170323-083538-Berlin-Zoologischer-Garten-2017-2u4.mov", data.FileName)
|
2020-05-15 09:39:32 +02:00
|
|
|
assert.Equal(t, CodecAvc1, data.Codec)
|
|
|
|
assert.Equal(t, "3s", data.Duration.String())
|
2020-12-22 07:47:16 +01:00
|
|
|
assert.Equal(t, "2018-09-08 19:20:14 +0000 UTC", data.TakenAtLocal.String())
|
|
|
|
assert.Equal(t, "2018-09-08 17:20:14 +0000 UTC", data.TakenAt.String())
|
2020-05-15 09:39:32 +02:00
|
|
|
assert.Equal(t, "Europe/Berlin", data.TimeZone)
|
2020-06-04 14:56:27 +02:00
|
|
|
assert.Equal(t, 1920, data.Width)
|
|
|
|
assert.Equal(t, 1080, data.Height)
|
|
|
|
assert.Equal(t, 1080, data.ActualWidth())
|
|
|
|
assert.Equal(t, 1920, data.ActualHeight())
|
|
|
|
assert.Equal(t, 6, data.Orientation)
|
2020-05-15 09:39:32 +02:00
|
|
|
assert.Equal(t, float32(52.4587), data.Lat)
|
|
|
|
assert.Equal(t, float32(13.4593), data.Lng)
|
|
|
|
assert.Equal(t, "Apple", data.CameraMake)
|
|
|
|
assert.Equal(t, "iPhone SE", data.CameraModel)
|
|
|
|
assert.Equal(t, "", data.LensModel)
|
|
|
|
})
|
|
|
|
|
2020-05-14 14:28:23 +02:00
|
|
|
t.Run("gopher-telegram.json", func(t *testing.T) {
|
2020-06-04 14:56:27 +02:00
|
|
|
data, err := JSON("testdata/gopher-telegram.json", "")
|
2020-05-13 20:53:15 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.Logf("DATA: %+v", data)
|
|
|
|
|
2020-05-15 09:39:32 +02:00
|
|
|
assert.Equal(t, CodecAvc1, data.Codec)
|
2020-05-14 14:28:23 +02:00
|
|
|
assert.Equal(t, "2s", data.Duration.String())
|
|
|
|
assert.Equal(t, "2020-05-11 14:18:35 +0000 UTC", data.TakenAtLocal.String())
|
|
|
|
assert.Equal(t, "2020-05-11 14:18:35 +0000 UTC", data.TakenAt.String())
|
2021-07-13 17:56:26 +02:00
|
|
|
assert.Equal(t, time.UTC.String(), data.TimeZone)
|
2020-05-14 14:28:23 +02:00
|
|
|
assert.Equal(t, 270, data.Width)
|
2020-05-13 20:53:15 +02:00
|
|
|
assert.Equal(t, 480, data.Height)
|
2020-06-04 14:56:27 +02:00
|
|
|
assert.Equal(t, 270, data.ActualWidth())
|
|
|
|
assert.Equal(t, 480, data.ActualHeight())
|
|
|
|
assert.Equal(t, 1, data.Orientation)
|
2020-05-14 14:28:23 +02:00
|
|
|
assert.Equal(t, float32(0), data.Lat)
|
|
|
|
assert.Equal(t, float32(0), data.Lng)
|
2020-05-13 20:53:15 +02:00
|
|
|
assert.Equal(t, "", data.CameraMake)
|
|
|
|
assert.Equal(t, "", data.CameraModel)
|
|
|
|
assert.Equal(t, "", data.LensModel)
|
|
|
|
})
|
|
|
|
|
2020-05-14 14:28:23 +02:00
|
|
|
t.Run("gopher-original.json", func(t *testing.T) {
|
2020-06-04 14:56:27 +02:00
|
|
|
data, err := JSON("testdata/gopher-original.json", "")
|
2020-05-14 11:57:26 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.Logf("DATA: %+v", data)
|
|
|
|
|
2020-05-15 09:39:32 +02:00
|
|
|
assert.Equal(t, CodecAvc1, data.Codec)
|
2020-05-14 11:57:26 +02:00
|
|
|
assert.Equal(t, "2s", data.Duration.String())
|
2021-07-13 17:56:26 +02:00
|
|
|
assert.Equal(t, "2020-05-11 16:16:48 +0000 UTC", data.TakenAtLocal.String())
|
|
|
|
assert.Equal(t, "2020-05-11 14:16:48 +0000 UTC", data.TakenAt.String())
|
2020-05-14 14:28:23 +02:00
|
|
|
assert.Equal(t, "Europe/Berlin", data.TimeZone)
|
2020-06-04 14:56:27 +02:00
|
|
|
assert.Equal(t, 1920, data.Width)
|
|
|
|
assert.Equal(t, 1080, data.Height)
|
|
|
|
assert.Equal(t, 1080, data.ActualWidth())
|
|
|
|
assert.Equal(t, 1920, data.ActualHeight())
|
2020-07-20 19:48:31 +02:00
|
|
|
assert.Equal(t, float32(0.56), data.AspectRatio())
|
2020-06-04 14:56:27 +02:00
|
|
|
assert.Equal(t, 6, data.Orientation)
|
2020-05-14 14:28:23 +02:00
|
|
|
assert.Equal(t, float32(52.4596), data.Lat)
|
|
|
|
assert.Equal(t, float32(13.3218), data.Lng)
|
|
|
|
assert.Equal(t, "", data.CameraMake)
|
|
|
|
assert.Equal(t, "", data.CameraModel)
|
|
|
|
assert.Equal(t, "", data.LensModel)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("berlin-landscape.json", func(t *testing.T) {
|
2020-06-04 14:56:27 +02:00
|
|
|
data, err := JSON("testdata/berlin-landscape.json", "")
|
2020-05-14 14:28:23 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.Logf("DATA: %+v", data)
|
|
|
|
|
2020-05-15 09:39:32 +02:00
|
|
|
assert.Equal(t, CodecAvc1, data.Codec)
|
2020-05-14 14:28:23 +02:00
|
|
|
assert.Equal(t, "4s", data.Duration.String())
|
2021-07-13 17:56:26 +02:00
|
|
|
assert.Equal(t, "2020-05-14 13:34:41 +0000 UTC", data.TakenAtLocal.String())
|
|
|
|
assert.Equal(t, "2020-05-14 11:34:41 +0000 UTC", data.TakenAt.String())
|
2020-05-14 14:28:23 +02:00
|
|
|
assert.Equal(t, "Europe/Berlin", data.TimeZone)
|
|
|
|
assert.Equal(t, 1920, data.Width)
|
|
|
|
assert.Equal(t, 1080, data.Height)
|
2020-06-04 14:56:27 +02:00
|
|
|
assert.Equal(t, 1, data.Orientation)
|
2020-05-14 14:28:23 +02:00
|
|
|
assert.Equal(t, float32(52.4649), data.Lat)
|
|
|
|
assert.Equal(t, float32(13.3148), data.Lng)
|
|
|
|
assert.Equal(t, "", data.CameraMake)
|
|
|
|
assert.Equal(t, "", data.CameraModel)
|
|
|
|
assert.Equal(t, "", data.LensModel)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("mp4.json", func(t *testing.T) {
|
2020-06-04 14:56:27 +02:00
|
|
|
data, err := JSON("testdata/mp4.json", "")
|
2020-05-14 14:28:23 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.Logf("DATA: %+v", data)
|
|
|
|
|
2020-05-15 09:39:32 +02:00
|
|
|
assert.Equal(t, CodecAvc1, data.Codec)
|
2020-05-14 14:28:23 +02:00
|
|
|
assert.Equal(t, "4m25s", data.Duration.String())
|
|
|
|
assert.Equal(t, "2019-11-23 13:51:49 +0000 UTC", data.TakenAtLocal.String())
|
|
|
|
assert.Equal(t, 848, data.Width)
|
2020-05-14 11:57:26 +02:00
|
|
|
assert.Equal(t, 480, data.Height)
|
2020-06-04 14:56:27 +02:00
|
|
|
assert.Equal(t, 1, data.Orientation)
|
2020-05-14 11:57:26 +02:00
|
|
|
assert.Equal(t, "", data.Copyright)
|
|
|
|
assert.Equal(t, "", data.CameraMake)
|
|
|
|
assert.Equal(t, "", data.CameraModel)
|
|
|
|
assert.Equal(t, "", data.LensModel)
|
|
|
|
})
|
|
|
|
|
2020-05-13 20:53:15 +02:00
|
|
|
t.Run("photoshop.json", func(t *testing.T) {
|
2020-06-04 14:56:27 +02:00
|
|
|
data, err := JSON("testdata/photoshop.json", "")
|
2020-05-13 20:53:15 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.Logf("DATA: %+v", data)
|
2022-01-06 09:55:41 +01:00
|
|
|
assert.Equal(t, "photoshop.xmp", data.FileName)
|
2020-05-27 13:40:21 +02:00
|
|
|
assert.Equal(t, CodecXMP, data.Codec)
|
2020-05-14 11:57:26 +02:00
|
|
|
assert.Equal(t, "0s", data.Duration.String())
|
|
|
|
assert.Equal(t, float32(52.45969), data.Lat)
|
|
|
|
assert.Equal(t, float32(13.321831), data.Lng)
|
|
|
|
assert.Equal(t, "2020-01-01 16:28:23 +0000 UTC", data.TakenAt.String())
|
|
|
|
assert.Equal(t, "2020-01-01 17:28:23 +0000 UTC", data.TakenAtLocal.String())
|
|
|
|
assert.Equal(t, "Europe/Berlin", data.TimeZone)
|
2020-05-13 20:53:15 +02:00
|
|
|
assert.Equal(t, "Night Shift / Berlin / 2020", data.Title)
|
|
|
|
assert.Equal(t, "Michael Mayer", data.Artist)
|
|
|
|
assert.Equal(t, "Example file for development", data.Description)
|
|
|
|
assert.Equal(t, "This is an (edited) legal notice", data.Copyright)
|
|
|
|
assert.Equal(t, "HUAWEI", data.CameraMake)
|
|
|
|
assert.Equal(t, "ELE-L29", data.CameraModel)
|
|
|
|
assert.Equal(t, "HUAWEI P30 Rear Main Camera", data.LensModel)
|
2020-06-04 14:56:27 +02:00
|
|
|
assert.Equal(t, 1, data.Orientation)
|
2020-05-13 20:53:15 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("canon_eos_6d.json", func(t *testing.T) {
|
2020-06-04 14:56:27 +02:00
|
|
|
data, err := JSON("testdata/canon_eos_6d.json", "")
|
2020-05-13 20:53:15 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.Logf("DATA: %+v", data)
|
|
|
|
|
2022-02-07 12:41:11 +01:00
|
|
|
assert.Equal(t, CodecXMP, data.Codec)
|
2020-05-13 20:53:15 +02:00
|
|
|
assert.Equal(t, "", data.Title)
|
|
|
|
assert.Equal(t, "", data.Artist)
|
|
|
|
assert.Equal(t, "", data.Description)
|
|
|
|
assert.Equal(t, "", data.Copyright)
|
|
|
|
assert.Equal(t, "Canon", data.CameraMake)
|
|
|
|
assert.Equal(t, "Canon EOS 6D", data.CameraModel)
|
|
|
|
assert.Equal(t, "EF24-105mm f/4L IS USM", data.LensModel)
|
2020-06-04 14:56:27 +02:00
|
|
|
assert.Equal(t, 1, data.Orientation)
|
2020-05-13 20:53:15 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("gps-2000.json", func(t *testing.T) {
|
2020-06-04 14:56:27 +02:00
|
|
|
data, err := JSON("testdata/gps-2000.json", "")
|
2020-05-13 20:53:15 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.Logf("DATA: %+v", data)
|
|
|
|
|
2020-05-15 09:39:32 +02:00
|
|
|
assert.Equal(t, CodecUnknown, data.Codec)
|
2020-05-13 20:53:15 +02:00
|
|
|
assert.Equal(t, "", data.Title)
|
|
|
|
assert.Equal(t, "", data.Artist)
|
|
|
|
assert.Equal(t, "", data.Description)
|
|
|
|
assert.Equal(t, "", data.Copyright)
|
|
|
|
assert.Equal(t, "", data.CameraMake)
|
|
|
|
assert.Equal(t, "", data.CameraModel)
|
|
|
|
assert.Equal(t, "", data.LensMake)
|
|
|
|
assert.Equal(t, "", data.LensModel)
|
2020-06-04 14:56:27 +02:00
|
|
|
assert.Equal(t, 1, data.Orientation)
|
2020-05-13 20:53:15 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("ladybug.json", func(t *testing.T) {
|
2020-06-04 14:56:27 +02:00
|
|
|
data, err := JSON("testdata/ladybug.json", "")
|
2020-05-13 20:53:15 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.Logf("DATA: %+v", data)
|
|
|
|
|
2020-05-15 09:39:32 +02:00
|
|
|
assert.Equal(t, CodecUnknown, data.Codec)
|
2020-05-13 20:53:15 +02:00
|
|
|
assert.Equal(t, "", data.Title)
|
|
|
|
assert.Equal(t, "", data.Artist)
|
|
|
|
assert.Equal(t, "", data.Description)
|
|
|
|
assert.Equal(t, "", data.Copyright)
|
|
|
|
assert.Equal(t, "", data.CameraMake)
|
|
|
|
assert.Equal(t, "", data.CameraModel)
|
|
|
|
assert.Equal(t, "", data.LensMake)
|
|
|
|
assert.Equal(t, "", data.LensModel)
|
2020-06-04 14:56:27 +02:00
|
|
|
assert.Equal(t, 1, data.Orientation)
|
2020-05-13 20:53:15 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("iphone_7.json", func(t *testing.T) {
|
2020-06-04 14:56:27 +02:00
|
|
|
data, err := JSON("testdata/iphone_7.json", "")
|
2020-05-13 20:53:15 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.Logf("DATA: %+v", data)
|
|
|
|
|
2020-05-27 13:40:21 +02:00
|
|
|
assert.Equal(t, CodecHeic, data.Codec)
|
2020-05-13 20:53:15 +02:00
|
|
|
assert.Equal(t, "", data.Title)
|
|
|
|
assert.Equal(t, "", data.Artist)
|
|
|
|
assert.Equal(t, "", data.Description)
|
|
|
|
assert.Equal(t, "", data.Copyright)
|
2020-06-04 14:56:27 +02:00
|
|
|
assert.Equal(t, 6, data.Orientation)
|
2020-05-13 20:53:15 +02:00
|
|
|
assert.Equal(t, "Apple", data.CameraMake)
|
|
|
|
assert.Equal(t, "iPhone 7", data.CameraModel)
|
|
|
|
assert.Equal(t, "Apple", data.LensMake)
|
|
|
|
assert.Equal(t, "iPhone 7 back camera 3.99mm f/1.8", data.LensModel)
|
|
|
|
})
|
|
|
|
|
2020-05-27 13:40:21 +02:00
|
|
|
t.Run("uuid-original.json", func(t *testing.T) {
|
2020-06-04 14:56:27 +02:00
|
|
|
data, err := JSON("testdata/uuid-original.json", "")
|
2020-05-27 13:40:21 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.Logf("DATA: %+v", data)
|
|
|
|
|
|
|
|
assert.Equal(t, "9bafc58c-6c82-4e66-a45f-c13f915f99c5", data.DocumentID)
|
|
|
|
assert.Equal(t, "", data.InstanceID)
|
|
|
|
assert.Equal(t, CodecJpeg, data.Codec)
|
|
|
|
assert.Equal(t, "0s", data.Duration.String())
|
|
|
|
assert.Equal(t, "2018-12-06 12:32:26 +0000 UTC", data.TakenAtLocal.String())
|
|
|
|
assert.Equal(t, "2018-12-06 11:32:26 +0000 UTC", data.TakenAt.String())
|
|
|
|
assert.Equal(t, "Europe/Berlin", data.TimeZone)
|
|
|
|
assert.Equal(t, 3024, data.Width)
|
|
|
|
assert.Equal(t, 4032, data.Height)
|
2020-06-04 14:56:27 +02:00
|
|
|
assert.Equal(t, 1, data.Orientation)
|
2020-05-27 13:40:21 +02:00
|
|
|
assert.Equal(t, float32(48.300003), data.Lat)
|
|
|
|
assert.Equal(t, float32(8.929067), data.Lng)
|
|
|
|
assert.Equal(t, "Apple", data.CameraMake)
|
|
|
|
assert.Equal(t, "iPhone SE", data.CameraModel)
|
|
|
|
assert.Equal(t, "iPhone SE back camera 4.15mm f/2.2", data.LensModel)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("uuid-copy.json", func(t *testing.T) {
|
2020-06-04 14:56:27 +02:00
|
|
|
data, err := JSON("testdata/uuid-copy.json", "")
|
2020-05-27 13:40:21 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.Logf("DATA: %+v", data)
|
|
|
|
|
2020-07-23 15:34:20 +02:00
|
|
|
assert.Equal(t, "", data.DocumentID)
|
2020-05-27 13:40:21 +02:00
|
|
|
assert.Equal(t, "dafbfeb8-a129-4e7c-9cf0-e7996a701cdb", data.InstanceID)
|
|
|
|
assert.Equal(t, CodecJpeg, data.Codec)
|
|
|
|
assert.Equal(t, "0s", data.Duration.String())
|
|
|
|
assert.Equal(t, "2018-12-06 12:32:26 +0000 UTC", data.TakenAtLocal.String())
|
|
|
|
assert.Equal(t, "2018-12-06 11:32:26 +0000 UTC", data.TakenAt.String())
|
|
|
|
assert.Equal(t, "Europe/Berlin", data.TimeZone)
|
|
|
|
assert.Equal(t, 1024, data.Width)
|
|
|
|
assert.Equal(t, 1365, data.Height)
|
2020-06-04 14:56:27 +02:00
|
|
|
assert.Equal(t, 1, data.Orientation)
|
2020-05-27 13:40:21 +02:00
|
|
|
assert.Equal(t, float32(48.300003), data.Lat)
|
|
|
|
assert.Equal(t, float32(8.929067), data.Lng)
|
|
|
|
assert.Equal(t, "Apple", data.CameraMake)
|
|
|
|
assert.Equal(t, "iPhone SE", data.CameraModel)
|
|
|
|
assert.Equal(t, "iPhone SE back camera 4.15mm f/2.2", data.LensModel)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("uuid-imagemagick.json", func(t *testing.T) {
|
2020-06-04 14:56:27 +02:00
|
|
|
data, err := JSON("testdata/uuid-imagemagick.json", "")
|
2020-05-27 13:40:21 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.Logf("DATA: %+v", data)
|
|
|
|
|
|
|
|
assert.Equal(t, "9bafc58c-6c82-4e66-a45f-c13f915f99c5", data.DocumentID)
|
|
|
|
assert.Equal(t, "", data.InstanceID)
|
|
|
|
assert.Equal(t, CodecJpeg, data.Codec)
|
|
|
|
assert.Equal(t, "0s", data.Duration.String())
|
|
|
|
assert.Equal(t, "2018-12-06 12:32:26 +0000 UTC", data.TakenAtLocal.String())
|
|
|
|
assert.Equal(t, "2018-12-06 11:32:26 +0000 UTC", data.TakenAt.String())
|
|
|
|
assert.Equal(t, "Europe/Berlin", data.TimeZone)
|
|
|
|
assert.Equal(t, 1125, data.Width)
|
|
|
|
assert.Equal(t, 1500, data.Height)
|
2020-06-04 14:56:27 +02:00
|
|
|
assert.Equal(t, 1, data.Orientation)
|
2020-05-27 13:40:21 +02:00
|
|
|
assert.Equal(t, float32(48.300003), data.Lat)
|
|
|
|
assert.Equal(t, float32(8.929067), data.Lng)
|
|
|
|
assert.Equal(t, "Apple", data.CameraMake)
|
|
|
|
assert.Equal(t, "iPhone SE", data.CameraModel)
|
|
|
|
assert.Equal(t, "iPhone SE back camera 4.15mm f/2.2", data.LensModel)
|
|
|
|
})
|
2020-06-04 14:56:27 +02:00
|
|
|
|
|
|
|
t.Run("orientation.json", func(t *testing.T) {
|
|
|
|
data, err := JSON("testdata/orientation.json", "")
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Equal(t, 326, data.Width)
|
|
|
|
assert.Equal(t, 184, data.Height)
|
|
|
|
assert.Equal(t, 1, data.Orientation)
|
|
|
|
})
|
2020-07-11 16:46:29 +02:00
|
|
|
|
|
|
|
t.Run("gphotos-1.json", func(t *testing.T) {
|
|
|
|
data, err := JSON("testdata/gphotos-1.json", "")
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Equal(t, "", data.Title)
|
|
|
|
assert.Equal(t, "", data.Description)
|
|
|
|
assert.Equal(t, "2015-12-06 16:18:30 +0000 UTC", data.TakenAtLocal.String())
|
|
|
|
assert.Equal(t, "2015-12-06 15:18:30 +0000 UTC", data.TakenAt.String())
|
|
|
|
assert.Equal(t, "Europe/Berlin", data.TimeZone)
|
|
|
|
assert.Equal(t, float32(52.508522), data.Lat)
|
|
|
|
assert.Equal(t, float32(13.443206), data.Lng)
|
|
|
|
assert.Equal(t, 40, data.Altitude)
|
|
|
|
assert.Equal(t, 0, data.Views)
|
|
|
|
|
|
|
|
assert.Equal(t, "", data.DocumentID)
|
|
|
|
assert.Equal(t, "", data.InstanceID)
|
|
|
|
assert.Equal(t, CodecUnknown, data.Codec)
|
|
|
|
assert.Equal(t, "0s", data.Duration.String())
|
|
|
|
assert.Equal(t, 0, data.Width)
|
|
|
|
assert.Equal(t, 0, data.Height)
|
|
|
|
assert.Equal(t, 0, data.Orientation)
|
|
|
|
assert.Equal(t, "", data.CameraMake)
|
|
|
|
assert.Equal(t, "", data.CameraModel)
|
|
|
|
assert.Equal(t, "", data.LensModel)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("gphotos-2.json", func(t *testing.T) {
|
|
|
|
data, err := JSON("testdata/gphotos-2.json", "")
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Equal(t, "", data.Title)
|
|
|
|
assert.Equal(t, "A photo description", data.Description)
|
|
|
|
assert.Equal(t, "2019-05-18 12:06:45 +0000 UTC", data.TakenAtLocal.String())
|
|
|
|
assert.Equal(t, "2019-05-18 10:06:45 +0000 UTC", data.TakenAt.String())
|
|
|
|
assert.Equal(t, "Europe/Berlin", data.TimeZone)
|
|
|
|
assert.Equal(t, float32(52.510796), data.Lat)
|
|
|
|
assert.Equal(t, float32(13.456387), data.Lng)
|
|
|
|
assert.Equal(t, 0, data.Altitude)
|
|
|
|
assert.Equal(t, 1118, data.Views)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("gphotos-3.json", func(t *testing.T) {
|
|
|
|
data, err := JSON("testdata/gphotos-3.json", "")
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Equal(t, "Bei den Landungsbrücken", data.Title)
|
|
|
|
assert.Equal(t, "In Hamburg", data.Description)
|
|
|
|
assert.Equal(t, "2011-11-07 21:34:34 +0000 UTC", data.TakenAtLocal.String())
|
|
|
|
assert.Equal(t, "2011-11-07 21:34:34 +0000 UTC", data.TakenAt.String())
|
|
|
|
assert.Equal(t, "", data.TimeZone)
|
|
|
|
assert.Equal(t, float32(0), data.Lat)
|
|
|
|
assert.Equal(t, float32(0), data.Lng)
|
|
|
|
assert.Equal(t, 0, data.Altitude)
|
|
|
|
assert.Equal(t, 177, data.Views)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("gphotos-4.json", func(t *testing.T) {
|
|
|
|
data, err := JSON("testdata/gphotos-4.json", "")
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Equal(t, "", data.Title)
|
|
|
|
assert.Equal(t, "", data.Description)
|
|
|
|
assert.Equal(t, "2012-12-11 00:07:15 +0000 UTC", data.TakenAtLocal.String())
|
|
|
|
assert.Equal(t, "2012-12-10 23:07:15 +0000 UTC", data.TakenAt.String())
|
|
|
|
assert.Equal(t, "Europe/Berlin", data.TimeZone)
|
|
|
|
assert.Equal(t, float32(52.49967), data.Lat)
|
|
|
|
assert.Equal(t, float32(13.422334), data.Lng)
|
|
|
|
assert.Equal(t, 0, data.Altitude)
|
|
|
|
assert.Equal(t, 0, data.Views)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("gphotos-album.json", func(t *testing.T) {
|
|
|
|
data, err := JSON("testdata/gphotos-album.json", "")
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.True(t, data.TakenAtLocal.IsZero())
|
|
|
|
assert.True(t, data.TakenAt.IsZero())
|
|
|
|
assert.Equal(t, 0, data.Views)
|
|
|
|
|
|
|
|
if len(data.Albums) == 1 {
|
|
|
|
assert.Equal(t, "iPhone", data.Albums[0])
|
|
|
|
} else {
|
|
|
|
assert.Len(t, data.Albums, 1)
|
|
|
|
}
|
|
|
|
})
|
2020-07-16 13:02:48 +02:00
|
|
|
|
|
|
|
t.Run("panorama360.json", func(t *testing.T) {
|
|
|
|
data, err := JSON("testdata/panorama360.json", "panorama360.jpg")
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.Logf("all: %+v", data.All)
|
|
|
|
|
|
|
|
assert.Equal(t, "", data.Artist)
|
|
|
|
assert.Equal(t, "2020-05-24T08:55:21Z", data.TakenAt.Format("2006-01-02T15:04:05Z"))
|
|
|
|
assert.Equal(t, "2020-05-24T11:55:21Z", data.TakenAtLocal.Format("2006-01-02T15:04:05Z"))
|
|
|
|
assert.Equal(t, "", data.Title)
|
2021-04-25 14:17:34 +02:00
|
|
|
assert.Equal(t, "panorama", data.Keywords.String())
|
2020-07-16 13:02:48 +02:00
|
|
|
assert.Equal(t, "", data.Description)
|
|
|
|
assert.Equal(t, "", data.Copyright)
|
|
|
|
assert.Equal(t, 3600, data.Height)
|
|
|
|
assert.Equal(t, 7200, data.Width)
|
|
|
|
assert.Equal(t, float32(59.84083), data.Lat)
|
|
|
|
assert.Equal(t, float32(30.51), data.Lng)
|
|
|
|
assert.Equal(t, 0, data.Altitude)
|
|
|
|
assert.Equal(t, "1/1250", data.Exposure)
|
|
|
|
assert.Equal(t, "SAMSUNG", data.CameraMake)
|
|
|
|
assert.Equal(t, "SM-C200", data.CameraModel)
|
|
|
|
assert.Equal(t, "", data.CameraOwner)
|
|
|
|
assert.Equal(t, "", data.CameraSerial)
|
|
|
|
assert.Equal(t, 0, data.FocalLength)
|
|
|
|
assert.Equal(t, 1, data.Orientation)
|
|
|
|
assert.Equal(t, "equirectangular", data.Projection)
|
|
|
|
})
|
2020-10-04 12:47:53 +02:00
|
|
|
|
|
|
|
t.Run("P7250006.json", func(t *testing.T) {
|
|
|
|
data, err := JSON("testdata/P7250006.json", "P7250006.MOV")
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.Logf("all: %+v", data.All)
|
|
|
|
|
|
|
|
assert.Equal(t, "", data.Artist)
|
|
|
|
assert.Equal(t, "2018-07-25T11:18:42Z", data.TakenAt.Format("2006-01-02T15:04:05Z"))
|
|
|
|
assert.Equal(t, "2018-07-25T11:18:42Z", data.TakenAtLocal.Format("2006-01-02T15:04:05Z"))
|
|
|
|
assert.Equal(t, "", data.Title)
|
2021-04-25 14:17:34 +02:00
|
|
|
assert.Equal(t, "", data.Keywords.String())
|
2020-10-04 12:47:53 +02:00
|
|
|
assert.Equal(t, "", data.Description)
|
|
|
|
assert.Equal(t, "", data.Copyright)
|
|
|
|
assert.Equal(t, 1080, data.Height)
|
|
|
|
assert.Equal(t, 1920, 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, "OLYMPUS DIGITAL CAMERA", data.CameraMake)
|
|
|
|
assert.Equal(t, "E-PL7", data.CameraModel)
|
|
|
|
assert.Equal(t, "", data.CameraOwner)
|
|
|
|
assert.Equal(t, "", data.CameraSerial)
|
|
|
|
assert.Equal(t, 0, data.FocalLength)
|
|
|
|
assert.Equal(t, 1, data.Orientation)
|
|
|
|
assert.Equal(t, "", data.Projection)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("P9150300.json", func(t *testing.T) {
|
|
|
|
data, err := JSON("testdata/P9150300.json", "P9150300.MOV")
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.Logf("all: %+v", data.All)
|
|
|
|
|
|
|
|
assert.Equal(t, "OLYMPUS DIGITAL CAMERA", data.CameraMake)
|
|
|
|
assert.Equal(t, "E-M10MarkII", data.CameraModel)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("GOPR0533.json", func(t *testing.T) {
|
|
|
|
data, err := JSON("testdata/GOPR0533.json", "GOPR0533.MP4")
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// No make or model in this file...
|
|
|
|
assert.Equal(t, "", data.CameraMake)
|
|
|
|
assert.Equal(t, "", data.CameraModel)
|
|
|
|
})
|
2020-10-19 11:50:54 +02:00
|
|
|
|
|
|
|
t.Run("digikam.json", func(t *testing.T) {
|
|
|
|
data, err := JSON("testdata/digikam.json", "")
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2021-07-12 21:41:44 +02:00
|
|
|
assert.Equal(t, string(fs.CodecJpeg), data.Codec)
|
2020-10-19 11:50:54 +02:00
|
|
|
assert.Equal(t, "", data.Artist)
|
|
|
|
assert.Equal(t, "2020-10-17T15:48:24Z", data.TakenAt.Format("2006-01-02T15:04:05Z"))
|
|
|
|
assert.Equal(t, "2020-10-17T17:48:24Z", data.TakenAtLocal.Format("2006-01-02T15:04:05Z"))
|
|
|
|
assert.Equal(t, "Europe/Berlin", data.TimeZone)
|
|
|
|
assert.Equal(t, "", data.Title)
|
2021-04-25 14:17:34 +02:00
|
|
|
assert.Equal(t, "berlin, shop", data.Keywords.String())
|
2020-10-19 11:50:54 +02:00
|
|
|
assert.Equal(t, "", data.Description)
|
|
|
|
assert.Equal(t, "", data.Copyright)
|
|
|
|
assert.Equal(t, 375, data.Height)
|
|
|
|
assert.Equal(t, 500, data.Width)
|
|
|
|
assert.Equal(t, float32(52.46052), data.Lat)
|
|
|
|
assert.Equal(t, float32(13.331403), data.Lng)
|
2021-07-12 21:41:44 +02:00
|
|
|
assert.Equal(t, 84, data.Altitude)
|
2020-10-19 11:50:54 +02:00
|
|
|
assert.Equal(t, "1/50", data.Exposure)
|
|
|
|
assert.Equal(t, "HUAWEI", data.CameraMake)
|
|
|
|
assert.Equal(t, "ELE-L29", data.CameraModel)
|
|
|
|
assert.Equal(t, "", data.CameraOwner)
|
|
|
|
assert.Equal(t, "", data.CameraSerial)
|
|
|
|
assert.Equal(t, "", data.LensMake)
|
|
|
|
assert.Equal(t, "", data.LensModel)
|
|
|
|
assert.Equal(t, 0, data.FocalLength)
|
|
|
|
assert.Equal(t, 1, int(data.Orientation))
|
|
|
|
})
|
2020-12-22 01:52:36 +01:00
|
|
|
|
|
|
|
t.Run("date.mov.json", func(t *testing.T) {
|
|
|
|
data, err := JSON("testdata/date.mov.json", "")
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Equal(t, CodecAvc1, data.Codec)
|
|
|
|
assert.Equal(t, "6s", data.Duration.String())
|
|
|
|
assert.Equal(t, "2015-06-10 14:06:09 +0000 UTC", data.TakenAtLocal.String())
|
|
|
|
assert.Equal(t, "2015-06-10 11:06:09 +0000 UTC", data.TakenAt.String())
|
|
|
|
assert.Equal(t, "Europe/Moscow", data.TimeZone)
|
|
|
|
assert.Equal(t, 1920, data.Width)
|
|
|
|
assert.Equal(t, 1080, data.Height)
|
|
|
|
assert.Equal(t, 1080, data.ActualWidth())
|
|
|
|
assert.Equal(t, 1920, data.ActualHeight())
|
|
|
|
assert.Equal(t, 6, data.Orientation)
|
|
|
|
assert.Equal(t, float32(55.5636), data.Lat)
|
|
|
|
assert.Equal(t, float32(37.9824), data.Lng)
|
|
|
|
assert.Equal(t, "Apple", data.CameraMake)
|
|
|
|
assert.Equal(t, "iPhone 6 Plus", data.CameraModel)
|
|
|
|
assert.Equal(t, "", data.LensModel)
|
|
|
|
})
|
2020-12-22 07:47:16 +01:00
|
|
|
|
|
|
|
t.Run("date-creation.mov.json", func(t *testing.T) {
|
|
|
|
data, err := JSON("testdata/date-creation.mov.json", "")
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Equal(t, string(fs.CodecAvc), data.Codec)
|
|
|
|
assert.Equal(t, "10s", data.Duration.String())
|
|
|
|
assert.Equal(t, "2015-12-06 18:22:29 +0000 UTC", data.TakenAtLocal.String())
|
|
|
|
assert.Equal(t, "2015-12-06 15:22:29 +0000 UTC", data.TakenAt.String())
|
|
|
|
assert.Equal(t, "Europe/Moscow", data.TimeZone)
|
|
|
|
assert.Equal(t, 1920, data.Width)
|
|
|
|
assert.Equal(t, 1080, data.Height)
|
|
|
|
assert.Equal(t, 1920, data.ActualWidth())
|
|
|
|
assert.Equal(t, 1080, data.ActualHeight())
|
|
|
|
assert.Equal(t, 1, data.Orientation)
|
|
|
|
assert.Equal(t, float32(55.7579), data.Lat)
|
|
|
|
assert.Equal(t, float32(37.6197), data.Lng)
|
|
|
|
assert.Equal(t, "Apple", data.CameraMake)
|
|
|
|
assert.Equal(t, "iPhone 6 Plus", data.CameraModel)
|
|
|
|
assert.Equal(t, "", data.LensModel)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("date-iphone8.mov.json", func(t *testing.T) {
|
|
|
|
data, err := JSON("testdata/date-iphone8.mov.json", "")
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Equal(t, string(fs.CodecHvc), data.Codec)
|
|
|
|
assert.Equal(t, "6s", data.Duration.String())
|
|
|
|
assert.Equal(t, "2020-12-22 02:45:43 +0000 UTC", data.TakenAtLocal.String())
|
|
|
|
assert.Equal(t, "2020-12-22 01:45:43 +0000 UTC", data.TakenAt.String())
|
|
|
|
assert.Equal(t, "", data.TimeZone)
|
|
|
|
assert.Equal(t, 1920, data.Width)
|
|
|
|
assert.Equal(t, 1080, data.Height)
|
|
|
|
assert.Equal(t, 1080, data.ActualWidth())
|
|
|
|
assert.Equal(t, 1920, data.ActualHeight())
|
|
|
|
assert.Equal(t, 6, data.Orientation)
|
|
|
|
assert.Equal(t, float32(0), data.Lat)
|
|
|
|
assert.Equal(t, float32(0), data.Lng)
|
|
|
|
assert.Equal(t, "Apple", data.CameraMake)
|
|
|
|
assert.Equal(t, "iPhone 8", data.CameraModel)
|
|
|
|
assert.Equal(t, "", data.LensModel)
|
|
|
|
})
|
2020-12-22 09:43:19 +01:00
|
|
|
|
|
|
|
t.Run("date-iphonex.mov.json", func(t *testing.T) {
|
|
|
|
data, err := JSON("testdata/date-iphonex.mov.json", "")
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Equal(t, string(fs.CodecHvc), data.Codec)
|
|
|
|
assert.Equal(t, "2s", data.Duration.String())
|
|
|
|
assert.Equal(t, "2019-12-12 20:47:21 +0000 UTC", data.TakenAtLocal.String())
|
|
|
|
assert.Equal(t, "2019-12-13 01:47:21 +0000 UTC", data.TakenAt.String())
|
|
|
|
assert.Equal(t, "America/New_York", data.TimeZone)
|
|
|
|
assert.Equal(t, 1, data.Orientation)
|
|
|
|
assert.Equal(t, float32(40.7696), data.Lat)
|
|
|
|
assert.Equal(t, float32(-73.9964), data.Lng)
|
|
|
|
assert.Equal(t, "Apple", data.CameraMake)
|
|
|
|
assert.Equal(t, "iPhone X", data.CameraModel)
|
|
|
|
assert.Equal(t, "", data.LensModel)
|
|
|
|
})
|
2020-12-23 18:43:52 +01:00
|
|
|
|
|
|
|
t.Run("snow.json", func(t *testing.T) {
|
|
|
|
data, err := JSON("testdata/snow.json", "")
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Equal(t, string(fs.CodecJpeg), data.Codec)
|
|
|
|
assert.Equal(t, "0s", data.Duration.String())
|
|
|
|
assert.Equal(t, "2015-03-20 12:07:53 +0000 UTC", data.TakenAtLocal.String())
|
|
|
|
assert.Equal(t, "2015-03-20 12:07:53 +0000 UTC", data.TakenAt.String())
|
|
|
|
assert.Equal(t, "", data.TimeZone)
|
|
|
|
assert.Equal(t, 4608, data.Width)
|
|
|
|
assert.Equal(t, 3072, data.Height)
|
|
|
|
assert.Equal(t, 4608, data.ActualWidth())
|
|
|
|
assert.Equal(t, 3072, data.ActualHeight())
|
|
|
|
assert.Equal(t, 1, data.Orientation)
|
|
|
|
assert.Equal(t, float32(0), data.Lat)
|
|
|
|
assert.Equal(t, float32(0), data.Lng)
|
|
|
|
assert.Equal(t, "OLYMPUS IMAGING CORP.", data.CameraMake)
|
|
|
|
assert.Equal(t, "TG-830", data.CameraModel)
|
|
|
|
assert.Equal(t, "", data.LensModel)
|
|
|
|
})
|
2020-12-31 13:51:31 +01:00
|
|
|
|
|
|
|
t.Run("subject-1.json", func(t *testing.T) {
|
|
|
|
data, err := JSON("testdata/subject-1.json", "")
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Equal(t, string(fs.CodecJpeg), data.Codec)
|
|
|
|
assert.Equal(t, "0s", data.Duration.String())
|
|
|
|
assert.Equal(t, "2016-09-07 12:49:23 +0000 UTC", data.TakenAtLocal.String())
|
|
|
|
assert.Equal(t, "2016-09-07 12:49:23 +0000 UTC", data.TakenAt.String())
|
|
|
|
assert.Equal(t, "", data.TimeZone)
|
|
|
|
assert.Equal(t, 4032, data.Width)
|
|
|
|
assert.Equal(t, 3024, data.Height)
|
|
|
|
assert.Equal(t, 4032, data.ActualWidth())
|
|
|
|
assert.Equal(t, 3024, data.ActualHeight())
|
|
|
|
assert.Equal(t, 1, data.Orientation)
|
|
|
|
assert.Equal(t, float32(0), data.Lat)
|
|
|
|
assert.Equal(t, float32(0), data.Lng)
|
|
|
|
assert.Equal(t, "Apple", data.CameraMake)
|
|
|
|
assert.Equal(t, "iPhone 6s", data.CameraModel)
|
|
|
|
assert.Equal(t, "iPhone 6s back camera 4.15mm f/2.2", data.LensModel)
|
|
|
|
assert.Equal(t, "holiday", data.Subject)
|
2021-04-25 14:17:34 +02:00
|
|
|
assert.Equal(t, "holiday", data.Keywords.String())
|
2020-12-31 13:51:31 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("subject-2.json", func(t *testing.T) {
|
|
|
|
data, err := JSON("testdata/subject-2.json", "")
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Equal(t, string(fs.CodecJpeg), data.Codec)
|
|
|
|
assert.Equal(t, "0s", data.Duration.String())
|
|
|
|
assert.Equal(t, "2016-09-07 12:49:23 +0000 UTC", data.TakenAtLocal.String())
|
|
|
|
assert.Equal(t, "2016-09-07 12:49:23 +0000 UTC", data.TakenAt.String())
|
|
|
|
assert.Equal(t, "", data.TimeZone)
|
|
|
|
assert.Equal(t, 4032, data.Width)
|
|
|
|
assert.Equal(t, 3024, data.Height)
|
|
|
|
assert.Equal(t, 4032, data.ActualWidth())
|
|
|
|
assert.Equal(t, 3024, data.ActualHeight())
|
|
|
|
assert.Equal(t, 1, data.Orientation)
|
|
|
|
assert.Equal(t, float32(0), data.Lat)
|
|
|
|
assert.Equal(t, float32(0), data.Lng)
|
|
|
|
assert.Equal(t, "Apple", data.CameraMake)
|
|
|
|
assert.Equal(t, "iPhone 6s", data.CameraModel)
|
|
|
|
assert.Equal(t, "iPhone 6s back camera 4.15mm f/2.2", data.LensModel)
|
|
|
|
assert.Equal(t, "holiday, greetings", data.Subject)
|
2021-04-25 14:17:34 +02:00
|
|
|
assert.Equal(t, "greetings, holiday", data.Keywords.String())
|
2020-12-31 13:51:31 +01:00
|
|
|
})
|
2021-02-13 18:11:44 +01:00
|
|
|
|
|
|
|
t.Run("newline.json", func(t *testing.T) {
|
|
|
|
data, err := JSON("testdata/newline.json", "newline.jpg")
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.Logf("all: %+v", data.All)
|
|
|
|
|
|
|
|
assert.Equal(t, "Jens\r\tMander", data.Artist)
|
2022-02-28 19:12:54 +01:00
|
|
|
assert.Equal(t, "2004-09-23T10:57:57Z", data.TakenAt.Format("2006-01-02T15:04:05Z"))
|
|
|
|
assert.Equal(t, "2004-09-23T10:57:57Z", data.TakenAtLocal.Format("2006-01-02T15:04:05Z"))
|
2021-02-13 18:11:44 +01:00
|
|
|
assert.Equal(t, "This is the title", data.Title)
|
2021-04-25 14:17:34 +02:00
|
|
|
assert.Equal(t, "", data.Keywords.String())
|
2021-02-13 18:11:44 +01:00
|
|
|
assert.Equal(t, "This is a\n\ndescription!", data.Description)
|
|
|
|
assert.Equal(t, "This is the world.", data.Subject)
|
|
|
|
assert.Equal(t, "© 2011 PhotoPrism", data.Copyright)
|
|
|
|
assert.Equal(t, 567, data.Height)
|
|
|
|
assert.Equal(t, 850, data.Width)
|
|
|
|
assert.Equal(t, float32(0), data.Lat)
|
|
|
|
assert.Equal(t, float32(0), data.Lng)
|
|
|
|
assert.Equal(t, 30, data.Altitude)
|
|
|
|
assert.Equal(t, "1/6", data.Exposure)
|
|
|
|
assert.Equal(t, "Canon", data.CameraMake)
|
|
|
|
assert.Equal(t, "Canon EOS-1DS", data.CameraModel)
|
|
|
|
assert.Equal(t, "", data.CameraOwner)
|
|
|
|
assert.Equal(t, "123456", data.CameraSerial)
|
|
|
|
assert.Equal(t, 0, data.FocalLength)
|
|
|
|
assert.Equal(t, 1, data.Orientation)
|
|
|
|
assert.Equal(t, "", data.Projection)
|
|
|
|
})
|
2021-05-01 10:52:28 +02:00
|
|
|
|
|
|
|
t.Run("keywords.json", func(t *testing.T) {
|
|
|
|
data, err := JSON("testdata/keywords.json", "")
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Equal(t, CodecJpeg, data.Codec)
|
|
|
|
assert.Equal(t, "", data.Title)
|
|
|
|
assert.Equal(t, "", data.Artist)
|
|
|
|
assert.Equal(t, Keywords{"alo", "cactus", "ever", "lang", "sonne"}, data.Keywords)
|
|
|
|
assert.Equal(t, "", data.Description)
|
|
|
|
assert.Equal(t, "", data.Copyright)
|
|
|
|
assert.Equal(t, "Canon", data.CameraMake)
|
|
|
|
assert.Equal(t, "Canon EOS 7D", data.CameraModel)
|
|
|
|
assert.Equal(t, "", data.LensMake)
|
|
|
|
assert.Equal(t, "EF70-200mm f/4L IS USM", data.LensModel)
|
|
|
|
assert.Equal(t, 1, data.Orientation)
|
|
|
|
})
|
2021-07-12 21:41:44 +02:00
|
|
|
|
|
|
|
t.Run("quicktimeutc_on.json", func(t *testing.T) {
|
|
|
|
data, err := JSON("testdata/quicktimeutc_on.json", "")
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Equal(t, string(fs.CodecAvc), data.Codec)
|
|
|
|
assert.Equal(t, "1s", data.Duration.String())
|
|
|
|
assert.Equal(t, "2012-07-11 07:16:01 +0000 UTC", data.TakenAtLocal.String())
|
|
|
|
assert.Equal(t, "2012-07-11 05:16:01 +0000 UTC", data.TakenAt.String())
|
|
|
|
assert.Equal(t, "Europe/Paris", data.TimeZone)
|
|
|
|
assert.Equal(t, 1, data.Orientation)
|
|
|
|
assert.Equal(t, float32(43.5683), data.Lat)
|
|
|
|
assert.Equal(t, float32(4.5645), data.Lng)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("quicktimeutc_off.json", func(t *testing.T) {
|
|
|
|
data, err := JSON("testdata/quicktimeutc_off.json", "")
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Equal(t, string(fs.CodecAvc), data.Codec)
|
|
|
|
assert.Equal(t, "1s", data.Duration.String())
|
|
|
|
assert.Equal(t, "2012-07-11 07:16:01 +0000 UTC", data.TakenAtLocal.String())
|
|
|
|
assert.Equal(t, "2012-07-11 05:16:01 +0000 UTC", data.TakenAt.String())
|
|
|
|
assert.Equal(t, "Europe/Paris", data.TimeZone)
|
|
|
|
assert.Equal(t, 1, data.Orientation)
|
|
|
|
assert.Equal(t, float32(43.5683), data.Lat)
|
|
|
|
assert.Equal(t, float32(4.5645), data.Lng)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("video_num_on.json", func(t *testing.T) {
|
|
|
|
data, err := JSON("testdata/video_num_on.json", "")
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Equal(t, string(fs.CodecAvc), data.Codec)
|
|
|
|
assert.Equal(t, "1s", data.Duration.String())
|
|
|
|
assert.Equal(t, "2012-07-11 07:16:01 +0000 UTC", data.TakenAtLocal.String())
|
|
|
|
assert.Equal(t, "2012-07-11 05:16:01 +0000 UTC", data.TakenAt.String())
|
|
|
|
assert.Equal(t, "Europe/Paris", data.TimeZone)
|
|
|
|
assert.Equal(t, 6, data.Orientation)
|
|
|
|
assert.Equal(t, float32(43.5683), data.Lat)
|
|
|
|
assert.Equal(t, float32(4.5645), data.Lng)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("cr2_num_off.json", func(t *testing.T) {
|
|
|
|
data, err := JSON("testdata/cr2_num_off.json", "")
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Equal(t, "2015-02-14T02:14:40Z", data.TakenAt.Format("2006-01-02T15:04:05Z"))
|
|
|
|
assert.Equal(t, "2015-02-13T18:14:40Z", data.TakenAtLocal.Format("2006-01-02T15:04:05Z"))
|
|
|
|
assert.Equal(t, 3648, data.Height)
|
|
|
|
assert.Equal(t, 5472, data.Width)
|
|
|
|
assert.Equal(t, float32(32.843544), data.Lat)
|
|
|
|
assert.Equal(t, float32(-117.28025), data.Lng)
|
|
|
|
assert.Equal(t, 18, data.Altitude)
|
|
|
|
assert.Equal(t, "1/500", data.Exposure)
|
|
|
|
assert.Equal(t, "Canon", data.CameraMake)
|
|
|
|
assert.Equal(t, "Canon EOS 6D", data.CameraModel)
|
|
|
|
assert.Equal(t, "", data.CameraOwner)
|
|
|
|
assert.Equal(t, "012324001432", data.CameraSerial)
|
|
|
|
assert.Equal(t, 0, data.FocalLength)
|
|
|
|
assert.Equal(t, 1, data.Orientation)
|
|
|
|
assert.Equal(t, "", data.Projection)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("cr2_num_on.json", func(t *testing.T) {
|
|
|
|
data, err := JSON("testdata/cr2_num_on.json", "")
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Equal(t, "2015-02-14T02:14:40Z", data.TakenAt.Format("2006-01-02T15:04:05Z"))
|
|
|
|
assert.Equal(t, "2015-02-13T18:14:40Z", data.TakenAtLocal.Format("2006-01-02T15:04:05Z"))
|
|
|
|
assert.Equal(t, 3648, data.Height)
|
|
|
|
assert.Equal(t, 5472, data.Width)
|
|
|
|
assert.Equal(t, float32(32.843544), data.Lat)
|
|
|
|
assert.Equal(t, float32(-117.28025), data.Lng)
|
|
|
|
assert.Equal(t, 18, data.Altitude)
|
|
|
|
assert.Equal(t, "0.002", data.Exposure)
|
|
|
|
assert.Equal(t, "Canon", data.CameraMake)
|
|
|
|
assert.Equal(t, "Canon EOS 6D", data.CameraModel)
|
|
|
|
assert.Equal(t, "", data.CameraOwner)
|
|
|
|
assert.Equal(t, "012324001432", data.CameraSerial)
|
2021-12-09 07:00:39 +01:00
|
|
|
assert.Equal(t, 35, data.FocalLength)
|
2021-07-12 21:41:44 +02:00
|
|
|
assert.Equal(t, 1, data.Orientation)
|
|
|
|
assert.Equal(t, "", data.Projection)
|
|
|
|
})
|
2021-07-13 17:56:26 +02:00
|
|
|
|
|
|
|
t.Run("pxl-mp4.json", func(t *testing.T) {
|
|
|
|
data, err := JSON("testdata/pxl-mp4.json", "")
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Equal(t, "2021-07-12T22:56:37Z", data.TakenAt.Format("2006-01-02T15:04:05Z"))
|
|
|
|
assert.Equal(t, "2021-07-12T22:56:37Z", data.TakenAtLocal.Format("2006-01-02T15:04:05Z"))
|
|
|
|
assert.Equal(t, time.UTC.String(), data.TimeZone)
|
|
|
|
assert.Equal(t, 1080, data.Height)
|
|
|
|
assert.Equal(t, 1920, 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, 1, data.Orientation)
|
|
|
|
})
|
2021-12-09 07:00:39 +01:00
|
|
|
|
2022-02-28 19:12:54 +01:00
|
|
|
t.Run("sony_mp4_exiftool.json", func(t *testing.T) {
|
|
|
|
data, err := JSON("testdata/sony_mp4_exiftool.json", "")
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Equal(t, "2021-07-06T13:51:36Z", data.TakenAt.Format("2006-01-02T15:04:05Z"))
|
|
|
|
assert.Equal(t, "2021-07-06T13:51:36Z", data.TakenAtLocal.Format("2006-01-02T15:04:05Z"))
|
|
|
|
assert.Equal(t, time.UTC.String(), data.TimeZone)
|
|
|
|
assert.Equal(t, 1080, data.Height)
|
|
|
|
assert.Equal(t, 1920, 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, 1, data.Orientation)
|
|
|
|
})
|
|
|
|
|
2021-12-09 07:00:39 +01:00
|
|
|
t.Run("Iceland-P3.jpg", func(t *testing.T) {
|
|
|
|
data, err := JSON("testdata/Iceland-P3.json", "")
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.Logf("all: %+v", data.All)
|
|
|
|
|
|
|
|
assert.Equal(t, "Nicolas Cornet", data.Artist)
|
|
|
|
assert.Equal(t, "2012-08-08T22:07:18Z", data.TakenAt.Format("2006-01-02T15:04:05Z"))
|
|
|
|
assert.Equal(t, "2012-08-08T22:07:18Z", data.TakenAtLocal.Format("2006-01-02T15:04:05Z"))
|
|
|
|
assert.Equal(t, "", data.Title)
|
|
|
|
assert.Equal(t, "", data.Keywords.String())
|
|
|
|
assert.Equal(t, "", data.Description)
|
|
|
|
assert.Equal(t, "Nicolas Cornet", data.Copyright)
|
|
|
|
assert.Equal(t, 400, data.Height)
|
|
|
|
assert.Equal(t, 600, data.Width)
|
|
|
|
assert.Equal(t, float32(65.05558), data.Lat)
|
|
|
|
assert.Equal(t, float32(-16.625702), data.Lng)
|
|
|
|
assert.Equal(t, 30, data.Altitude)
|
|
|
|
assert.Equal(t, "1/8", data.Exposure)
|
|
|
|
assert.Equal(t, "NIKON CORPORATION", data.CameraMake)
|
|
|
|
assert.Equal(t, "NIKON D800E", data.CameraModel)
|
|
|
|
assert.Equal(t, "", data.CameraOwner)
|
|
|
|
assert.Equal(t, "6001440", data.CameraSerial)
|
|
|
|
assert.Equal(t, 0, data.FocalLength)
|
|
|
|
assert.Equal(t, 1, data.Orientation)
|
|
|
|
assert.Equal(t, "", data.Projection)
|
|
|
|
assert.Equal(t, "Display P3", data.ColorProfile)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("Iceland-P3-n.jpg", func(t *testing.T) {
|
|
|
|
data, err := JSON("testdata/Iceland-P3-n.json", "")
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.Logf("all: %+v", data.All)
|
|
|
|
|
|
|
|
assert.Equal(t, "Nicolas Cornet", data.Artist)
|
|
|
|
assert.Equal(t, "2012-08-08T22:07:18Z", data.TakenAt.Format("2006-01-02T15:04:05Z"))
|
|
|
|
assert.Equal(t, "2012-08-08T22:07:18Z", data.TakenAtLocal.Format("2006-01-02T15:04:05Z"))
|
|
|
|
assert.Equal(t, "", data.Title)
|
|
|
|
assert.Equal(t, "", data.Keywords.String())
|
|
|
|
assert.Equal(t, "", data.Description)
|
|
|
|
assert.Equal(t, "Nicolas Cornet", data.Copyright)
|
|
|
|
assert.Equal(t, 400, data.Height)
|
|
|
|
assert.Equal(t, 600, data.Width)
|
|
|
|
assert.Equal(t, float32(65.05558), data.Lat)
|
|
|
|
assert.Equal(t, float32(-16.625702), data.Lng)
|
|
|
|
assert.Equal(t, 30, data.Altitude)
|
|
|
|
assert.Equal(t, "0.125", data.Exposure)
|
|
|
|
assert.Equal(t, "NIKON CORPORATION", data.CameraMake)
|
|
|
|
assert.Equal(t, "NIKON D800E", data.CameraModel)
|
|
|
|
assert.Equal(t, "", data.CameraOwner)
|
|
|
|
assert.Equal(t, "6001440", data.CameraSerial)
|
|
|
|
assert.Equal(t, 16, data.FocalLength)
|
|
|
|
assert.Equal(t, 1, data.Orientation)
|
|
|
|
assert.Equal(t, "", data.Projection)
|
|
|
|
assert.Equal(t, "Display P3", data.ColorProfile)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("Iceland-sRGB.jpg", func(t *testing.T) {
|
|
|
|
data, err := JSON("testdata/Iceland-sRGB.json", "")
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.Logf("all: %+v", data.All)
|
|
|
|
|
|
|
|
assert.Equal(t, "Nicolas Cornet", data.Artist)
|
|
|
|
assert.Equal(t, "2012-08-08T22:07:18Z", data.TakenAt.Format("2006-01-02T15:04:05Z"))
|
|
|
|
assert.Equal(t, "2012-08-08T22:07:18Z", data.TakenAtLocal.Format("2006-01-02T15:04:05Z"))
|
|
|
|
assert.Equal(t, "", data.Title)
|
|
|
|
assert.Equal(t, "", data.Keywords.String())
|
|
|
|
assert.Equal(t, "", data.Description)
|
|
|
|
assert.Equal(t, "Nicolas Cornet", data.Copyright)
|
|
|
|
assert.Equal(t, 400, data.Height)
|
|
|
|
assert.Equal(t, 600, data.Width)
|
|
|
|
assert.Equal(t, float32(65.05558), data.Lat)
|
|
|
|
assert.Equal(t, float32(-16.625702), data.Lng)
|
|
|
|
assert.Equal(t, 30, data.Altitude)
|
|
|
|
assert.Equal(t, "1/8", data.Exposure)
|
|
|
|
assert.Equal(t, "NIKON CORPORATION", data.CameraMake)
|
|
|
|
assert.Equal(t, "NIKON D800E", data.CameraModel)
|
|
|
|
assert.Equal(t, "", data.CameraOwner)
|
|
|
|
assert.Equal(t, "6001440", data.CameraSerial)
|
|
|
|
assert.Equal(t, 0, data.FocalLength)
|
|
|
|
assert.Equal(t, 1, data.Orientation)
|
|
|
|
assert.Equal(t, "", data.Projection)
|
|
|
|
assert.Equal(t, "Display P3", data.ColorProfile)
|
|
|
|
})
|
2020-05-13 20:53:15 +02:00
|
|
|
}
|