From ed9b1474fb776b5d586fc573b6581fcf3c9ce4f8 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Tue, 21 Jan 2025 19:11:40 +0800 Subject: [PATCH] :bug: Fix analyzer panic --- pkg/internal/services/analyzer.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/internal/services/analyzer.go b/pkg/internal/services/analyzer.go index 9513c6f..ef18bfc 100644 --- a/pkg/internal/services/analyzer.go +++ b/pkg/internal/services/analyzer.go @@ -99,8 +99,8 @@ func ScanUnanalyzedFileFromDatabase() { }() } -func calculateAspectRatio(width, height int, orientation int) float64 { - if orientation == 6 || orientation == 8 { +func calculateAspectRatio(width, height int, orientation string) float64 { + if orientation == "6" || orientation == "8" { width, height = height, width } return float64(width) / float64(height) @@ -173,7 +173,7 @@ func AnalyzeAttachment(file models.Attachment) error { for _, data := range exif { for k := range data.Fields { if k == "Orientation" { - file.Metadata["ratio"] = calculateAspectRatio(width, height, data.Fields[k].(int)) + file.Metadata["ratio"] = calculateAspectRatio(width, height, data.Fields[k].(string)) } if strings.HasPrefix(k, "GPS") { data.Clear(k) @@ -217,7 +217,7 @@ func AnalyzeAttachment(file models.Attachment) error { for _, data := range exif { for k := range data.Fields { if k == "Orientation" { - file.Metadata["ratio"] = calculateAspectRatio(stream.Width, stream.Height, data.Fields[k].(int)) + file.Metadata["ratio"] = calculateAspectRatio(stream.Width, stream.Height, data.Fields[k].(string)) } if strings.HasPrefix(k, "GPS") { data.Clear(k)