From d6db5b36b9d69f0ed7b7fe53c7d2ea208a19ff78 Mon Sep 17 00:00:00 2001 From: "SylikC (admin)" Date: Wed, 17 Jul 2019 01:21:41 -0700 Subject: [PATCH] Merge pull request 27 https://github.com/smarnach/pyexiftool/pull/27 which also exists in a different repo https://github.com/blurstudio/pyexiftool/tree/shell-option --- CHANGELOG.md | 1 + exiftool.py | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 71aa296..7473dd9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ Date (Timezone) | Version | Comment 07/17/2019 12:50:20 AM (PDT) | 0.1 | Convert leading spaces to tabs 07/17/2019 12:52:33 AM (PDT) | 0.1.1 | Merge [Pull request #10 "add copy_tags method"](https://github.com/smarnach/pyexiftool/pull/10) by [Maik Riechert (letmaik) Cambridge, UK](https://github.com/letmaik) on May 28, 2014
*This adds a small convenience method to copy any tags from one file to another. I use it for several month now and it works fine for me.* 07/17/2019 01:05:37 AM (PDT) | 0.1.2 | Merge [Pull request #25 "Added option for keeping print conversion active. #25"](https://github.com/smarnach/pyexiftool/pull/25) by [Bernhard Bliem (bbliem)](https://github.com/bbliem) on Jan 17, 2019
*For some tags, disabling print conversion (as was the default before) would not make much sense. For example, if print conversion is deactivated, the value of the Composite:LensID tag could be reported as something like "8D 44 5C 8E 34 3C 8F 0E". It is doubtful whether this is useful here, as we would then need to look up what this means in a table supplied with exiftool. We would probably like the human-readable value, which is in this case "AF-S DX Zoom-Nikkor 18-70mm f/3.5-4.5G IF-ED".*
*Disabling print conversion makes sense for a lot of tags (e.g., it's nicer to get as the exposure time not the string "1/2" but the number 0.5). In such cases, even if we enable print conversion, we can disable it for individual tags by appending a # symbol to the tag name.* +07/17/2019 01:20:15 AM (PDT) | 0.1.3 | Merge with slight modifications to variable names for clarity (Kevin Mak) [Pull request #27 "Add "shell" keyword argument to ExifTool initialization"](https://github.com/smarnach/pyexiftool/pull/27) by [Douglas Lassance (douglaslassance) Los Angeles, CA](https://github.com/douglaslassance) on 5/29/2019
*On Windows this will allow to run exiftool without showing the DOS shell.*
**This might break Linux but I don't know for sure**
Alternative source location with only this patch: https://github.com/blurstudio/pyexiftool/tree/shell-option diff --git a/exiftool.py b/exiftool.py index 327d17f..f464f57 100644 --- a/exiftool.py +++ b/exiftool.py @@ -153,7 +153,8 @@ class ExifTool(object): associated with a running subprocess. """ - def __init__(self, executable_=None, print_conversion=False): + def __init__(self, executable_=None, win_shell=True, print_conversion=False): + self.win_shell = win_shell self.print_conversion = print_conversion if executable_ is None: self.executable = executable @@ -179,10 +180,17 @@ def start(self): command.append("-n") with open(os.devnull, "w") as devnull: + startup_info = subprocess.STARTUPINFO() + if not self.win_shell: + SW_FORCEMINIMIZE = 11 # from win32con + # Adding enum 11 (SW_FORCEMINIMIZE in win32api speak) will + # keep it from throwing up a DOS shell when it launches. + startup_info.dwFlags |= 11 + self._process = subprocess.Popen( command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, - stderr=devnull) + stderr=devnull, startupinfo=startup_info) self.running = True def terminate(self):