1
Fork 0

Fix exiftool detection

This commit is contained in:
viktorstrate 2021-04-03 21:39:32 +02:00
parent ad60eccf8b
commit ceb8c4103f
No known key found for this signature in database
GPG Key ID: 3F855605109C1E8A
2 changed files with 22 additions and 6 deletions

View File

@ -14,6 +14,22 @@ type exifParser interface {
ParseExif(media *models.Media) (*models.MediaEXIF, error)
}
var use_exiftool bool = false
func InitializeEXIFParser() {
// Decide between internal or external Exif parser
et, err := exiftool.NewExiftool()
if err != nil {
use_exiftool = false
log.Printf("Failed to get exiftool, using internal exif parser instead: %v\n", err)
} else {
et.Close()
log.Println("Found exiftool")
use_exiftool = true
}
}
// SaveEXIF scans the media file for exif metadata and saves it in the database if found
func SaveEXIF(tx *gorm.DB, media *models.Media) (*models.MediaEXIF, error) {
@ -32,14 +48,11 @@ func SaveEXIF(tx *gorm.DB, media *models.Media) (*models.MediaEXIF, error) {
}
}
// Decide between internal or external Exif parser
et, err := exiftool.NewExiftool()
et.Close()
var parser exifParser
if err != nil {
parser = &internalExifParser{}
} else {
if use_exiftool {
parser = &externalExifParser{}
} else {
parser = &internalExifParser{}
}
exif, err := parser.ParseExif(media)

View File

@ -16,6 +16,7 @@ import (
"github.com/photoview/photoview/api/graphql/dataloader"
"github.com/photoview/photoview/api/routes"
"github.com/photoview/photoview/api/scanner"
"github.com/photoview/photoview/api/scanner/exif"
"github.com/photoview/photoview/api/scanner/face_detection"
"github.com/photoview/photoview/api/server"
"github.com/photoview/photoview/api/utils"
@ -55,6 +56,8 @@ func main() {
scanner.InitializeExecutableWorkers()
exif.InitializeEXIFParser()
if err := face_detection.InitializeFaceDetector(db); err != nil {
log.Panicf("Could not initialize face detector: %s\n", err)
}