Skip to content

Video editing with Python

Try both ImageMagick binaries convert.exe and magick.exe (#1689)

Nexarius67308f8ca9ad
diff --git a/moviepy/config.py b/moviepy/config.py
index 20563e59..2dcb3973 100644
--- a/moviepy/config.py
+++ b/moviepy/config.py
@@ -66,19 +66,22 @@ if IMAGEMAGICK_BINARY == "auto-detect":
IMAGEMAGICK_BINARY = wr.QueryValueEx(key, "BinPath")[0] + r"\magick.exe"
key.Close()
except Exception:
- try:
- imagemagick_path = sp.check_output(
- r'dir /B /O-N "C:\Program Files\ImageMagick-*"',
- shell=True,
- encoding="utf-8",
- ).split("\n")[0]
- IMAGEMAGICK_BINARY = sp.check_output( # pragma: no cover
- rf'dir /B /S "C:\Program Files\{imagemagick_path}\*convert.exe"',
- shell=True,
- encoding="utf-8",
- ).split("\n")[0]
- except Exception:
- IMAGEMAGICK_BINARY = "unset"
+ for imagemagick_filename in ["convert.exe", "magick.exe"]:
+ try:
+ imagemagick_path = sp.check_output(
+ r'dir /B /O-N "C:\\Program Files\\ImageMagick-*"',
+ shell=True,
+ encoding="utf-8",
+ ).split("\n")[0]
+ IMAGEMAGICK_BINARY = sp.check_output( # pragma: no cover
+ rf'dir /B /S "C:\Program Files\{imagemagick_path}\''
+ f'*{imagemagick_filename}"',
+ shell=True,
+ encoding="utf-8",
+ ).split("\n")[0]
+ break
+ except Exception:
+ IMAGEMAGICK_BINARY = "unset"
if IMAGEMAGICK_BINARY in ["unset", "auto-detect"]:
if try_cmd(["convert"])[0]: