Backend: Use actual instead of original dimensions from metadata #304
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
parent
0bf17206d0
commit
7f2b13bf71
4 changed files with 14 additions and 14 deletions
|
@ -38,8 +38,8 @@ type Data struct {
|
|||
Lat float32 `meta:"-"`
|
||||
Lng float32 `meta:"-"`
|
||||
Altitude int `meta:"GlobalAltitude"`
|
||||
Width int `meta:"ImageWidth"`
|
||||
Height int `meta:"ImageHeight"`
|
||||
Width int `meta:"PixelXDimension,ImageWidth,ExifImageWidth,SourceImageWidth"`
|
||||
Height int `meta:"PixelYDimension,ImageHeight,ImageLength,ExifImageHeight,SourceImageHeight"`
|
||||
Orientation int `meta:"-"`
|
||||
Rotation int `meta:"Rotation"`
|
||||
All map[string]string
|
||||
|
|
|
@ -256,21 +256,21 @@ func (data *Data) Exif(fileName string) (err error) {
|
|||
data.UniqueID = value
|
||||
}
|
||||
|
||||
if value, ok := tags["ImageWidth"]; ok {
|
||||
if value, ok := tags["PixelXDimension"]; ok {
|
||||
if i, err := strconv.Atoi(value); err == nil {
|
||||
data.Width = i
|
||||
}
|
||||
} else if value, ok := tags["PixelXDimension"]; ok {
|
||||
} else if value, ok := tags["ImageWidth"]; ok {
|
||||
if i, err := strconv.Atoi(value); err == nil {
|
||||
data.Width = i
|
||||
}
|
||||
}
|
||||
|
||||
if value, ok := tags["ImageLength"]; ok {
|
||||
if value, ok := tags["PixelYDimension"]; ok {
|
||||
if i, err := strconv.Atoi(value); err == nil {
|
||||
data.Height = i
|
||||
}
|
||||
} else if value, ok := tags["PixelYDimension"]; ok {
|
||||
} else if value, ok := tags["ImageLength"]; ok {
|
||||
if i, err := strconv.Atoi(value); err == nil {
|
||||
data.Height = i
|
||||
}
|
||||
|
|
|
@ -19,8 +19,8 @@ func TestExif(t *testing.T) {
|
|||
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)
|
||||
assert.Equal(t, 2736, data.Height)
|
||||
assert.Equal(t, 3648, data.Width)
|
||||
assert.Equal(t, 540, data.Height)
|
||||
assert.Equal(t, 720, data.Width)
|
||||
assert.Equal(t, float32(52.45969), data.Lat)
|
||||
assert.Equal(t, float32(13.321832), data.Lng)
|
||||
assert.Equal(t, 0, data.Altitude)
|
||||
|
@ -84,8 +84,8 @@ func TestExif(t *testing.T) {
|
|||
assert.Equal(t, "", data.Keywords)
|
||||
assert.Equal(t, "DCIM\\100GOPRO", data.Description)
|
||||
assert.Equal(t, "", data.Copyright)
|
||||
assert.Equal(t, 2880, data.Height)
|
||||
assert.Equal(t, 3840, data.Width)
|
||||
assert.Equal(t, 180, data.Height)
|
||||
assert.Equal(t, 240, data.Width)
|
||||
assert.Equal(t, float32(0), data.Lng)
|
||||
assert.Equal(t, 0, data.Altitude)
|
||||
assert.Equal(t, "1/2462", data.Exposure)
|
||||
|
|
|
@ -41,8 +41,8 @@ func TestMediaFile_Exif_JPEG(t *testing.T) {
|
|||
assert.Equal(t, float32(-33.45347), info.Lat)
|
||||
assert.Equal(t, float32(25.764645), info.Lng)
|
||||
assert.Equal(t, 190, info.Altitude)
|
||||
assert.Equal(t, 2048, info.Width)
|
||||
assert.Equal(t, 1365, info.Height)
|
||||
assert.Equal(t, 497, info.Width)
|
||||
assert.Equal(t, 331, info.Height)
|
||||
assert.Equal(t, false, info.Flash)
|
||||
assert.Equal(t, "", info.Description)
|
||||
t.Logf("UTC: %s", info.TakenAt.String())
|
||||
|
@ -74,8 +74,8 @@ func TestMediaFile_Exif_JPEG(t *testing.T) {
|
|||
assert.Equal(t, float32(10), info.FNumber)
|
||||
assert.Equal(t, 200, info.Iso)
|
||||
assert.Equal(t, 0, info.Altitude)
|
||||
assert.Equal(t, 2048, info.Width)
|
||||
assert.Equal(t, 2048, info.Height)
|
||||
assert.Equal(t, 331, info.Width)
|
||||
assert.Equal(t, 331, info.Height)
|
||||
assert.Equal(t, true, info.Flash)
|
||||
assert.Equal(t, "", info.Description)
|
||||
t.Logf("UTC: %s", info.TakenAt.String())
|
||||
|
|
Loading…
Reference in a new issue