photonixapp/photonix

Speed up exiftool

Vlad1mir-D opened this issue · 3 comments

Is your feature request related to a problem? Please describe.
Exiftool took a lot of computing resources constantly during the background rescan of photos.
There are multiple ways to speed up ExifTool:

  • Use -fastN CLI flag
  • Use -stay_open CLI flag and communicate via a file

Describe the solution you'd like
Consider using -fastN (depending on which will be suitable for Photonix) and -stay_open that will reduce the load on CPU heavily.

Describe alternatives you've considered
I already increased the background rescan interval.

Additional context
Check this thread: https://exiftool.org/forum/index.php?topic=4134.0

Hi @Vlad1mir-D thanks for notifying us of this. It seems like -fast1 or -fast2 should be simple to try out. Ideally we should use -stay_open but it will take a bit of process management I think.

During my experiments, I found that -fast2 isn't suitable but -fast1 works well.
Patch for this is pretty simple:

diff --git a/photonix/photos/utils/metadata.py b/photonix/photos/utils/metadata.py
index a4016fc..1704833 100644
--- a/photonix/photos/utils/metadata.py
+++ b/photonix/photos/utils/metadata.py
@@ -13,7 +13,7 @@ class PhotoMetadata(object):
         self.data = {}
         try:
             # exiftool produces data such as MIME Type for non-photos too
-            result = Popen(['exiftool', path], stdout=PIPE, stdin=PIPE, stderr=PIPE).communicate()[0].decode('utf-8',
+            result = Popen(['exiftool', '-fast1', path], stdout=PIPE, stdin=PIPE, stderr=PIPE).communicate()[0].decod
         except UnicodeDecodeError:
             result = ''
         for line in str(result).split('\n'):

I hope to implement support for -stay_open in my spare time.

Thanks for trying this out @Vlad1mir-D and adding a patch. I'll give it a test and hopefully add it soon.