🐛 Analyzer now can handle EXIF Orientation
This commit is contained in:
parent
d0d14d7c67
commit
ac347540b8
@ -99,6 +99,13 @@ func ScanUnanalyzedFileFromDatabase() {
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func calculateAspectRatio(width, height int, orientation int) float64 {
|
||||||
|
if orientation == 6 || orientation == 8 {
|
||||||
|
width, height = height, width
|
||||||
|
}
|
||||||
|
return float64(width) / float64(height)
|
||||||
|
}
|
||||||
|
|
||||||
func AnalyzeAttachment(file models.Attachment) error {
|
func AnalyzeAttachment(file models.Attachment) error {
|
||||||
if file.Destination != models.AttachmentDstTemporary {
|
if file.Destination != models.AttachmentDstTemporary {
|
||||||
return fmt.Errorf("attachment isn't in temporary storage, unable to analyze")
|
return fmt.Errorf("attachment isn't in temporary storage, unable to analyze")
|
||||||
@ -133,7 +140,7 @@ func AnalyzeAttachment(file models.Attachment) error {
|
|||||||
"Model", "ShutterSpeed", "ISO", "Megapixels", "Aperture",
|
"Model", "ShutterSpeed", "ISO", "Megapixels", "Aperture",
|
||||||
"ColorSpace", "ColorTemperature", "ColorTone", "Contrast",
|
"ColorSpace", "ColorTemperature", "ColorTone", "Contrast",
|
||||||
"ExposureTime", "FNumber", "FocalLength", "Flash", "HDREffect",
|
"ExposureTime", "FNumber", "FocalLength", "Flash", "HDREffect",
|
||||||
"LensModel",
|
"LensModel", "Orientation",
|
||||||
}
|
}
|
||||||
|
|
||||||
switch strings.SplitN(file.MimeType, "/", 2)[0] {
|
switch strings.SplitN(file.MimeType, "/", 2)[0] {
|
||||||
@ -165,6 +172,9 @@ func AnalyzeAttachment(file models.Attachment) error {
|
|||||||
exif := et.ExtractMetadata(dst)
|
exif := et.ExtractMetadata(dst)
|
||||||
for _, data := range exif {
|
for _, data := range exif {
|
||||||
for k := range data.Fields {
|
for k := range data.Fields {
|
||||||
|
if k == "Orientation" {
|
||||||
|
file.Metadata["ratio"] = calculateAspectRatio(width, height, data.Fields[k].(int))
|
||||||
|
}
|
||||||
if strings.HasPrefix(k, "GPS") {
|
if strings.HasPrefix(k, "GPS") {
|
||||||
data.Clear(k)
|
data.Clear(k)
|
||||||
} else if lo.Contains(exifWhitelist, k) {
|
} else if lo.Contains(exifWhitelist, k) {
|
||||||
@ -206,6 +216,9 @@ func AnalyzeAttachment(file models.Attachment) error {
|
|||||||
exif := et.ExtractMetadata(dst)
|
exif := et.ExtractMetadata(dst)
|
||||||
for _, data := range exif {
|
for _, data := range exif {
|
||||||
for k := range data.Fields {
|
for k := range data.Fields {
|
||||||
|
if k == "Orientation" {
|
||||||
|
file.Metadata["ratio"] = calculateAspectRatio(stream.Width, stream.Height, data.Fields[k].(int))
|
||||||
|
}
|
||||||
if strings.HasPrefix(k, "GPS") {
|
if strings.HasPrefix(k, "GPS") {
|
||||||
data.Clear(k)
|
data.Clear(k)
|
||||||
} else if lo.Contains(exifWhitelist, k) {
|
} else if lo.Contains(exifWhitelist, k) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user