Skip to content

Commit

Permalink
🐛 Fix analyzer panic
Browse files Browse the repository at this point in the history
  • Loading branch information
LittleSheep2Code committed Jan 21, 2025
1 parent ac34754 commit ed9b147
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/internal/services/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit ed9b147

Please sign in to comment.