Backend: Fix panorama detection #352

Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
Michael Mayer 2020-07-17 10:10:01 +02:00
parent 716aa082d8
commit 13fe9af2fc
3 changed files with 14 additions and 6 deletions

View file

@ -226,5 +226,5 @@ func (m *File) Panorama() bool {
return false
}
return m.FileProjection != ProjectionDefault || m.FileWidth/m.FileHeight > 2
return m.FileProjection != ProjectionDefault || (m.FileWidth/m.FileHeight) >= 2
}

View file

@ -234,10 +234,18 @@ func TestFile_NoJPEG(t *testing.T) {
}
func TestFile_Panorama(t *testing.T) {
t.Run("true", func(t *testing.T) {
t.Run("3000", func(t *testing.T) {
file := &File{Photo: nil, FileType: "jpg", FileSidecar: false, FileWidth: 3000, FileHeight: 1000}
assert.True(t, file.Panorama())
})
t.Run("1999", func(t *testing.T) {
file := &File{Photo: nil, FileType: "jpg", FileSidecar: false, FileWidth: 1999, FileHeight: 1000}
assert.False(t, file.Panorama())
})
t.Run("2000", func(t *testing.T) {
file := &File{Photo: nil, FileType: "jpg", FileSidecar: false, FileWidth: 2000, FileHeight: 1000}
assert.True(t, file.Panorama())
})
t.Run("false", func(t *testing.T) {
file := &File{Photo: nil, FileType: "jpg", FileSidecar: false, FileWidth: 1500, FileHeight: 1000}
assert.False(t, file.Panorama())

View file

@ -403,10 +403,6 @@ func (ind *Index) MediaFile(m *MediaFile, o IndexOptions, originalName string) (
file.FileMissing = false
file.FileError = ""
if file.Panorama() {
photo.PhotoPanorama = true
}
// primary files are used for rendering thumbnails and image classification (plus sidecar files if they exist)
if file.FilePrimary {
primaryFile = file
@ -510,6 +506,10 @@ func (ind *Index) MediaFile(m *MediaFile, o IndexOptions, originalName string) (
photo.UpdateDateFields()
if file.Panorama() {
photo.PhotoPanorama = true
}
file.FileSidecar = m.IsSidecar()
file.FileVideo = m.IsVideo()
file.FileRoot = fileRoot