photonix icon indicating copy to clipboard operation
photonix copied to clipboard

Speed up exiftool

Open Vlad1mir-D opened this issue 4 years ago • 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

Vlad1mir-D avatar Oct 18 '21 14:10 Vlad1mir-D

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.

damianmoore avatar Oct 25 '21 15:10 damianmoore

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.

Vlad1mir-D avatar Oct 26 '21 20:10 Vlad1mir-D

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

damianmoore avatar Nov 18 '21 22:11 damianmoore