🐛 Fix analyzer panic
This commit is contained in:
parent
ac347540b8
commit
ed9b1474fb
@ -99,8 +99,8 @@ func ScanUnanalyzedFileFromDatabase() {
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
func calculateAspectRatio(width, height int, orientation int) float64 {
|
func calculateAspectRatio(width, height int, orientation string) float64 {
|
||||||
if orientation == 6 || orientation == 8 {
|
if orientation == "6" || orientation == "8" {
|
||||||
width, height = height, width
|
width, height = height, width
|
||||||
}
|
}
|
||||||
return float64(width) / float64(height)
|
return float64(width) / float64(height)
|
||||||
@ -173,7 +173,7 @@ func AnalyzeAttachment(file models.Attachment) error {
|
|||||||
for _, data := range exif {
|
for _, data := range exif {
|
||||||
for k := range data.Fields {
|
for k := range data.Fields {
|
||||||
if k == "Orientation" {
|
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") {
|
if strings.HasPrefix(k, "GPS") {
|
||||||
data.Clear(k)
|
data.Clear(k)
|
||||||
@ -217,7 +217,7 @@ func AnalyzeAttachment(file models.Attachment) error {
|
|||||||
for _, data := range exif {
|
for _, data := range exif {
|
||||||
for k := range data.Fields {
|
for k := range data.Fields {
|
||||||
if k == "Orientation" {
|
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") {
|
if strings.HasPrefix(k, "GPS") {
|
||||||
data.Clear(k)
|
data.Clear(k)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user