2020-01-07 17:36:49 +01:00
|
|
|
package meta
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2020-07-19 16:39:43 +02:00
|
|
|
"github.com/photoprism/photoprism/pkg/fs"
|
2020-01-07 17:36:49 +01:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestExif(t *testing.T) {
|
2020-05-06 08:03:57 +02:00
|
|
|
t.Run("photoshop.jpg", func(t *testing.T) {
|
2020-07-19 16:39:43 +02:00
|
|
|
data, err := Exif("testdata/photoshop.jpg", fs.TypeJpeg)
|
2020-01-19 13:27:15 +01:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Equal(t, "Michael Mayer", data.Artist)
|
|
|
|
assert.Equal(t, "2020-01-01T16:28:23Z", data.TakenAt.Format("2006-01-02T15:04:05Z"))
|
|
|
|
assert.Equal(t, "2020-01-01T17:28:23Z", data.TakenAtLocal.Format("2006-01-02T15:04:05Z"))
|
|
|
|
assert.Equal(t, "Example file for development", data.Description)
|
|
|
|
assert.Equal(t, "This is a legal notice", data.Copyright)
|
2020-05-18 17:38:14 +02:00
|
|
|
assert.Equal(t, 540, data.Height)
|
|
|
|
assert.Equal(t, 720, data.Width)
|
2020-04-26 11:41:54 +02:00
|
|
|
assert.Equal(t, float32(52.45969), data.Lat)
|
|
|
|
assert.Equal(t, float32(13.321832), data.Lng)
|
2020-01-19 13:27:15 +01:00
|
|
|
assert.Equal(t, 0, data.Altitude)
|
2020-04-26 12:17:49 +02:00
|
|
|
assert.Equal(t, "1/50", data.Exposure)
|
2020-01-19 13:27:15 +01:00
|
|
|
assert.Equal(t, "HUAWEI", data.CameraMake)
|
|
|
|
assert.Equal(t, "ELE-L29", data.CameraModel)
|
2020-02-07 14:40:06 +01:00
|
|
|
assert.Equal(t, "", data.CameraOwner)
|
|
|
|
assert.Equal(t, "", data.CameraSerial)
|
2020-01-19 13:27:15 +01:00
|
|
|
assert.Equal(t, 27, data.FocalLength)
|
|
|
|
assert.Equal(t, 1, int(data.Orientation))
|
|
|
|
|
|
|
|
// TODO: Values are empty - why?
|
|
|
|
// assert.Equal(t, "HUAWEI P30 Rear Main Camera", data.LensModel)
|
|
|
|
})
|
|
|
|
|
2020-05-06 08:03:57 +02:00
|
|
|
t.Run("ladybug.jpg", func(t *testing.T) {
|
2020-07-19 16:39:43 +02:00
|
|
|
data, err := Exif("testdata/ladybug.jpg", fs.TypeJpeg)
|
2020-02-07 14:40:06 +01:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2020-05-17 11:05:57 +02:00
|
|
|
// t.Logf("all: %+v", data.All)
|
2020-02-07 14:40:06 +01:00
|
|
|
|
|
|
|
assert.Equal(t, "Photographer: TMB", data.Artist)
|
|
|
|
assert.Equal(t, "2011-07-10T17:34:28Z", data.TakenAt.Format("2006-01-02T15:04:05Z"))
|
|
|
|
assert.Equal(t, "2011-07-10T19:34:28Z", data.TakenAtLocal.Format("2006-01-02T15:04:05Z"))
|
|
|
|
assert.Equal(t, "", data.Title) // Should be "Ladybug"
|
|
|
|
assert.Equal(t, "", data.Keywords) // Should be "Ladybug"
|
|
|
|
assert.Equal(t, "", data.Description)
|
|
|
|
assert.Equal(t, "", data.Copyright)
|
|
|
|
assert.Equal(t, 540, data.Height)
|
|
|
|
assert.Equal(t, 720, data.Width)
|
2020-04-26 11:41:54 +02:00
|
|
|
assert.Equal(t, float32(51.254852), data.Lat)
|
|
|
|
assert.Equal(t, float32(7.389468), data.Lng)
|
2020-02-07 14:40:06 +01:00
|
|
|
assert.Equal(t, 0, data.Altitude)
|
2020-04-26 12:17:49 +02:00
|
|
|
assert.Equal(t, "1/125", data.Exposure)
|
2020-02-07 14:40:06 +01:00
|
|
|
assert.Equal(t, "Canon", data.CameraMake)
|
|
|
|
assert.Equal(t, "Canon EOS 50D", data.CameraModel)
|
|
|
|
assert.Equal(t, "Thomas Meyer-Boudnik", data.CameraOwner)
|
|
|
|
assert.Equal(t, "2260716910", data.CameraSerial)
|
2020-05-17 11:05:57 +02:00
|
|
|
assert.Equal(t, "", data.LensMake)
|
|
|
|
assert.Equal(t, "EF100mm f/2.8 Macro USM", data.LensModel)
|
2020-02-07 14:40:06 +01:00
|
|
|
assert.Equal(t, 100, data.FocalLength)
|
|
|
|
assert.Equal(t, 1, int(data.Orientation))
|
|
|
|
})
|
|
|
|
|
2020-05-06 08:03:57 +02:00
|
|
|
t.Run("gopro_hd2.jpg", func(t *testing.T) {
|
2020-07-19 16:39:43 +02:00
|
|
|
data, err := Exif("testdata/gopro_hd2.jpg", fs.TypeJpeg)
|
2020-02-21 02:15:07 +01:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.Logf("all: %+v", data.All)
|
|
|
|
|
|
|
|
assert.Equal(t, "", data.Artist)
|
|
|
|
assert.Equal(t, "2017-12-21T05:17:28Z", data.TakenAt.Format("2006-01-02T15:04:05Z"))
|
|
|
|
assert.Equal(t, "2017-12-21T05:17:28Z", data.TakenAtLocal.Format("2006-01-02T15:04:05Z"))
|
2020-05-17 11:05:57 +02:00
|
|
|
assert.Equal(t, "", data.Title)
|
|
|
|
assert.Equal(t, "", data.Keywords)
|
2020-07-11 10:19:06 +02:00
|
|
|
assert.Equal(t, "", data.Description)
|
2020-02-21 02:15:07 +01:00
|
|
|
assert.Equal(t, "", data.Copyright)
|
2020-05-18 17:38:14 +02:00
|
|
|
assert.Equal(t, 180, data.Height)
|
|
|
|
assert.Equal(t, 240, data.Width)
|
2020-04-26 11:41:54 +02:00
|
|
|
assert.Equal(t, float32(0), data.Lng)
|
2020-02-21 02:15:07 +01:00
|
|
|
assert.Equal(t, 0, data.Altitude)
|
2020-04-26 12:17:49 +02:00
|
|
|
assert.Equal(t, "1/2462", data.Exposure)
|
2020-02-21 02:15:07 +01:00
|
|
|
assert.Equal(t, "GoPro", data.CameraMake)
|
|
|
|
assert.Equal(t, "HD2", data.CameraModel)
|
|
|
|
assert.Equal(t, "", data.CameraOwner)
|
|
|
|
assert.Equal(t, "", data.CameraSerial)
|
|
|
|
assert.Equal(t, 16, data.FocalLength)
|
|
|
|
assert.Equal(t, 1, int(data.Orientation))
|
|
|
|
})
|
|
|
|
|
2020-05-06 08:03:57 +02:00
|
|
|
t.Run("tweethog.png", func(t *testing.T) {
|
2020-07-19 16:39:43 +02:00
|
|
|
_, err := Exif("testdata/tweethog.png", fs.TypePng)
|
2020-01-19 13:27:15 +01:00
|
|
|
|
2020-05-15 15:29:56 +02:00
|
|
|
if err == nil {
|
|
|
|
t.Fatal("err should NOT be nil")
|
|
|
|
}
|
|
|
|
|
2020-07-16 20:32:45 +02:00
|
|
|
assert.Equal(t, "metadata: no exif header in tweethog.png (parse png)", err.Error())
|
2020-01-19 13:27:15 +01:00
|
|
|
})
|
|
|
|
|
2020-05-06 08:03:57 +02:00
|
|
|
t.Run("iphone_7.heic", func(t *testing.T) {
|
2020-07-19 16:39:43 +02:00
|
|
|
data, err := Exif("testdata/iphone_7.heic", fs.TypeHEIF)
|
2020-01-19 13:27:15 +01:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Equal(t, "2018-09-10T03:16:13Z", data.TakenAt.Format("2006-01-02T15:04:05Z"))
|
|
|
|
assert.Equal(t, "2018-09-10T12:16:13Z", data.TakenAtLocal.Format("2006-01-02T15:04:05Z"))
|
2020-04-26 11:41:54 +02:00
|
|
|
assert.Equal(t, float32(34.79745), data.Lat)
|
|
|
|
assert.Equal(t, float32(134.76463), data.Lng)
|
2020-01-19 13:27:15 +01:00
|
|
|
assert.Equal(t, 0, data.Altitude)
|
2020-04-26 12:17:49 +02:00
|
|
|
assert.Equal(t, "1/4000", data.Exposure)
|
2020-01-19 13:27:15 +01:00
|
|
|
assert.Equal(t, "Apple", data.CameraMake)
|
|
|
|
assert.Equal(t, "iPhone 7", data.CameraModel)
|
|
|
|
assert.Equal(t, 74, data.FocalLength)
|
2020-06-04 14:56:27 +02:00
|
|
|
assert.Equal(t, 6, data.Orientation)
|
2020-01-19 13:27:15 +01:00
|
|
|
assert.Equal(t, "Apple", data.LensMake)
|
|
|
|
assert.Equal(t, "iPhone 7 back camera 3.99mm f/1.8", data.LensModel)
|
|
|
|
|
|
|
|
})
|
2020-05-06 08:03:57 +02:00
|
|
|
|
|
|
|
t.Run("gps-2000.jpg", func(t *testing.T) {
|
2020-07-19 16:39:43 +02:00
|
|
|
data, err := Exif("testdata/gps-2000.jpg", fs.TypeJpeg)
|
2020-05-06 08:03:57 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2020-05-17 11:05:57 +02:00
|
|
|
// t.Logf("GPS 2000: %+v", data.All)
|
|
|
|
|
2020-05-06 08:03:57 +02:00
|
|
|
assert.Equal(t, "", data.Artist)
|
|
|
|
assert.True(t, data.TakenAt.IsZero())
|
|
|
|
assert.True(t, data.TakenAtLocal.IsZero())
|
|
|
|
assert.Equal(t, "", data.Description)
|
|
|
|
assert.Equal(t, "", data.Copyright)
|
2020-07-16 20:32:45 +02:00
|
|
|
assert.Equal(t, 3272, data.Height)
|
|
|
|
assert.Equal(t, 4940, data.Width)
|
2020-05-06 08:03:57 +02:00
|
|
|
assert.Equal(t, float32(-38.405193), data.Lat)
|
|
|
|
assert.Equal(t, float32(144.18896), 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, int(data.Orientation))
|
|
|
|
})
|
2020-05-15 11:15:15 +02:00
|
|
|
|
|
|
|
t.Run("image-2011.jpg", func(t *testing.T) {
|
2020-07-19 16:39:43 +02:00
|
|
|
data, err := Exif("testdata/image-2011.jpg", fs.TypeJpeg)
|
2020-05-15 11:15:15 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.Logf("ALL: %+v", data.All)
|
|
|
|
|
|
|
|
/*
|
|
|
|
Exiftool date information:
|
|
|
|
|
|
|
|
File Modification Date/Time : 2020:05:15 08:25:46+00:00
|
|
|
|
File Access Date/Time : 2020:05:15 08:25:47+00:00
|
|
|
|
File Inode Change Date/Time : 2020:05:15 08:25:46+00:00
|
|
|
|
Modify Date : 2020:05:15 10:25:45
|
|
|
|
Create Date : 2011:07:19 11:36:38
|
|
|
|
Metadata Date : 2020:05:15 10:25:45+02:00
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2020-05-17 11:05:57 +02:00
|
|
|
// assert.Equal(t, "2011-07-19T11:36:38Z", data.TakenAt.Format("2006-01-02T15:04:05Z")) // TODO
|
|
|
|
// assert.Equal(t, "2011-07-19T11:36:38Z", data.TakenAtLocal.Format("2006-01-02T15:04:05Z")) // TODO
|
2020-05-15 11:15:15 +02:00
|
|
|
assert.Equal(t, float32(0), data.Lat)
|
|
|
|
assert.Equal(t, float32(0), data.Lng)
|
|
|
|
assert.Equal(t, 0, data.Altitude)
|
|
|
|
assert.Equal(t, "1/1100", data.Exposure)
|
|
|
|
assert.Equal(t, "SAMSUNG", data.CameraMake)
|
|
|
|
assert.Equal(t, "GT-I9000", data.CameraModel)
|
|
|
|
assert.Equal(t, 3, data.FocalLength)
|
2020-05-15 12:45:42 +02:00
|
|
|
assert.Equal(t, 1, data.Orientation)
|
|
|
|
assert.Equal(t, "", data.LensMake)
|
|
|
|
assert.Equal(t, "", data.LensModel)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("ship.jpg", func(t *testing.T) {
|
2020-07-19 16:39:43 +02:00
|
|
|
data, err := Exif("testdata/ship.jpg", fs.TypeJpeg)
|
2020-05-15 12:45:42 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Equal(t, "2019-05-12T15:13:53Z", data.TakenAt.Format("2006-01-02T15:04:05Z"))
|
|
|
|
assert.Equal(t, "2019-05-12T17:13:53Z", data.TakenAtLocal.Format("2006-01-02T15:04:05Z"))
|
|
|
|
assert.Equal(t, float32(53.12349), data.Lat)
|
|
|
|
assert.Equal(t, float32(18.00152), data.Lng)
|
|
|
|
assert.Equal(t, 63, data.Altitude)
|
|
|
|
assert.Equal(t, "1/100", data.Exposure)
|
|
|
|
assert.Equal(t, "Xiaomi", data.CameraMake)
|
|
|
|
assert.Equal(t, "Mi A1", data.CameraModel)
|
|
|
|
assert.Equal(t, 52, data.FocalLength)
|
|
|
|
assert.Equal(t, 1, data.Orientation)
|
2020-05-15 11:15:15 +02:00
|
|
|
assert.Equal(t, "", data.LensMake)
|
|
|
|
assert.Equal(t, "", data.LensModel)
|
|
|
|
})
|
2020-05-15 15:29:56 +02:00
|
|
|
|
|
|
|
t.Run("no-exif-data.jpg", func(t *testing.T) {
|
2020-07-19 16:39:43 +02:00
|
|
|
_, err := Exif("testdata/no-exif-data.jpg", fs.TypeJpeg)
|
2020-05-15 15:29:56 +02:00
|
|
|
|
|
|
|
if err == nil {
|
|
|
|
t.Fatal("err should NOT be nil")
|
|
|
|
}
|
|
|
|
|
2020-07-02 08:26:15 +02:00
|
|
|
assert.Equal(t, "metadata: no exif header in no-exif-data.jpg (search and extract)", err.Error())
|
2020-05-15 15:29:56 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("screenshot.png", func(t *testing.T) {
|
2020-07-19 16:39:43 +02:00
|
|
|
data, err := Exif("testdata/screenshot.png", fs.TypePng)
|
2020-05-15 15:29:56 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Equal(t, "721", data.All["PixelXDimension"])
|
|
|
|
assert.Equal(t, "332", data.All["PixelYDimension"])
|
|
|
|
})
|
2020-06-04 14:56:27 +02:00
|
|
|
|
|
|
|
t.Run("orientation.jpg", func(t *testing.T) {
|
2020-07-19 16:39:43 +02:00
|
|
|
data, err := Exif("testdata/orientation.jpg", fs.TypeJpeg)
|
2020-06-04 14:56:27 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Equal(t, "3264", data.All["PixelXDimension"])
|
|
|
|
assert.Equal(t, "1836", data.All["PixelYDimension"])
|
|
|
|
assert.Equal(t, 3264, data.Width)
|
|
|
|
assert.Equal(t, 1836, data.Height)
|
|
|
|
assert.Equal(t, 6, data.Orientation) // TODO: Should be 1
|
|
|
|
|
|
|
|
if err := data.JSON("testdata/orientation.json", "orientation.jpg"); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.Equal(t, 326, data.Width)
|
|
|
|
assert.Equal(t, 184, data.Height)
|
|
|
|
assert.Equal(t, 1, data.Orientation)
|
|
|
|
|
|
|
|
if err := data.JSON("testdata/orientation.json", "foo.jpg"); err != nil {
|
2020-07-11 16:46:29 +02:00
|
|
|
assert.EqualError(t, err, "metadata: original name foo.jpg does not match orientation.jpg (exiftool)")
|
2020-06-04 14:56:27 +02:00
|
|
|
} else {
|
|
|
|
t.Error("error expected when providing wrong orginal name")
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("gopher-preview.jpg", func(t *testing.T) {
|
2020-07-19 16:39:43 +02:00
|
|
|
_, err := Exif("testdata/gopher-preview.jpg", fs.TypeJpeg)
|
2020-06-04 14:56:27 +02:00
|
|
|
|
2020-07-02 08:26:15 +02:00
|
|
|
assert.EqualError(t, err, "metadata: no exif header in gopher-preview.jpg (search and extract)")
|
2020-06-04 14:56:27 +02:00
|
|
|
})
|
2020-07-14 11:00:49 +02:00
|
|
|
|
|
|
|
t.Run("huawei-gps-error.jpg", func(t *testing.T) {
|
2020-07-19 16:39:43 +02:00
|
|
|
data, err := Exif("testdata/huawei-gps-error.jpg", fs.TypeJpeg)
|
2020-07-14 11:00:49 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2020-07-17 09:28:31 +02:00
|
|
|
assert.Equal(t, "2020-06-16T16:52:46Z", data.TakenAt.Format("2006-01-02T15:04:05Z"))
|
2020-07-14 11:00:49 +02:00
|
|
|
assert.Equal(t, "2020-06-16T18:52:46Z", data.TakenAtLocal.Format("2006-01-02T15:04:05Z"))
|
2020-07-17 09:28:31 +02:00
|
|
|
assert.Equal(t, float32(48.302776), data.Lat)
|
|
|
|
assert.Equal(t, float32(8.9275), data.Lng)
|
2020-07-14 11:00:49 +02:00
|
|
|
assert.Equal(t, 0, data.Altitude)
|
|
|
|
assert.Equal(t, "1/110", data.Exposure)
|
|
|
|
assert.Equal(t, "HUAWEI", data.CameraMake)
|
|
|
|
assert.Equal(t, "ELE-L29", data.CameraModel)
|
|
|
|
assert.Equal(t, 27, data.FocalLength)
|
|
|
|
assert.Equal(t, 0, data.Orientation)
|
|
|
|
assert.Equal(t, "", data.LensMake)
|
|
|
|
assert.Equal(t, "", data.LensModel)
|
|
|
|
})
|
2020-07-16 13:02:48 +02:00
|
|
|
|
|
|
|
t.Run("panorama360.jpg", func(t *testing.T) {
|
2020-07-19 16:39:43 +02:00
|
|
|
data, err := Exif("testdata/panorama360.jpg", fs.TypeJpeg)
|
2020-07-16 13:02:48 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.Logf("all: %+v", data.All)
|
|
|
|
|
|
|
|
assert.Equal(t, "", data.Artist)
|
2020-07-17 09:28:31 +02:00
|
|
|
assert.Equal(t, "2020-05-24T08:55:21Z", data.TakenAt.Format("2006-01-02T15:04:05Z"))
|
2020-07-16 13:02:48 +02:00
|
|
|
assert.Equal(t, "2020-05-24T11:55:21Z", data.TakenAtLocal.Format("2006-01-02T15:04:05Z"))
|
|
|
|
assert.Equal(t, "", data.Title)
|
|
|
|
assert.Equal(t, "", data.Keywords)
|
|
|
|
assert.Equal(t, "", data.Description)
|
|
|
|
assert.Equal(t, "", data.Copyright)
|
|
|
|
assert.Equal(t, 3600, data.Height)
|
|
|
|
assert.Equal(t, 7200, data.Width)
|
2020-07-17 09:28:31 +02:00
|
|
|
assert.Equal(t, float32(59.84083), data.Lat)
|
|
|
|
assert.Equal(t, float32(30.51), data.Lng)
|
2020-07-16 13:02:48 +02:00
|
|
|
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, 6, data.FocalLength)
|
2020-07-19 16:39:43 +02:00
|
|
|
assert.Equal(t, 0, data.Orientation)
|
|
|
|
assert.Equal(t, "", data.Projection)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("exif-example.tiff", func(t *testing.T) {
|
|
|
|
data, err := Exif("testdata/exif-example.tiff", fs.TypeTiff)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.Logf("all: %+v", data.All)
|
|
|
|
|
|
|
|
assert.Equal(t, "", data.Artist)
|
|
|
|
assert.Equal(t, "0001-01-01T00:00:00Z", data.TakenAt.Format("2006-01-02T15:04:05Z"))
|
|
|
|
assert.Equal(t, "0001-01-01T00:00:00Z", data.TakenAtLocal.Format("2006-01-02T15:04:05Z"))
|
|
|
|
assert.Equal(t, "", data.Title)
|
|
|
|
assert.Equal(t, "", data.Keywords)
|
|
|
|
assert.Equal(t, "", data.Description)
|
|
|
|
assert.Equal(t, "", data.Copyright)
|
|
|
|
assert.Equal(t, 43, data.Height)
|
|
|
|
assert.Equal(t, 65, 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)
|
2020-07-16 13:02:48 +02:00
|
|
|
assert.Equal(t, "", data.Projection)
|
|
|
|
})
|
2020-07-20 13:53:08 +02:00
|
|
|
|
|
|
|
t.Run("out-of-range-500.jpg", func(t *testing.T) {
|
|
|
|
data, err := Exif("testdata/out-of-range-500.jpg", fs.TypeJpeg)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// t.Logf("all: %+v", data.All)
|
|
|
|
|
|
|
|
assert.Equal(t, "", data.Artist)
|
|
|
|
assert.Equal(t, "2017-04-09T18:33:44Z", data.TakenAt.Format("2006-01-02T15:04:05Z"))
|
|
|
|
assert.Equal(t, "2017-04-09T18:33:44Z", data.TakenAtLocal.Format("2006-01-02T15:04:05Z"))
|
|
|
|
assert.Equal(t, "", data.Title)
|
|
|
|
assert.Equal(t, "", data.Keywords)
|
|
|
|
assert.Equal(t, "", data.Description)
|
|
|
|
assert.Equal(t, "", data.Copyright)
|
|
|
|
assert.Equal(t, 2448, data.Height)
|
|
|
|
assert.Equal(t, 3264, 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/387", data.Exposure)
|
|
|
|
assert.Equal(t, "Apple", data.CameraMake)
|
|
|
|
assert.Equal(t, "iPhone 5s", data.CameraModel)
|
|
|
|
assert.Equal(t, "", data.CameraOwner)
|
|
|
|
assert.Equal(t, "", data.CameraSerial)
|
|
|
|
assert.Equal(t, 29, data.FocalLength)
|
|
|
|
assert.Equal(t, 3, data.Orientation)
|
|
|
|
assert.Equal(t, "", data.Projection)
|
|
|
|
})
|
2020-01-07 17:36:49 +01:00
|
|
|
}
|