Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

auto detection of ImageMagick binary on Windows #118

Merged
merged 1 commit into from
Feb 5, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions moviepy/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
from subprocess import DEVNULL # py3k
except ImportError:
DEVNULL = open(os.devnull, 'wb')

if os.name == 'nt':
try:
import winreg as wr # py3k
except:
import _winreg as wr # py2k

from .config_defaults import (FFMPEG_BINARY, IMAGEMAGICK_BINARY)

Expand Down Expand Up @@ -48,11 +54,22 @@ def try_cmd(cmd):


if IMAGEMAGICK_BINARY=='auto-detect':

if try_cmd(['convert'])[0]:
if os.name == 'nt':
try:
key = wr.OpenKey(wr.HKEY_LOCAL_MACHINE, 'SOFTWARE\\ImageMagick\\Current')
IMAGEMAGICK_BINARY = wr.QueryValueEx(key, 'BinPath')[0] + r"\convert.exe"
key.Close()
except:
IMAGEMAGICK_BINARY = 'unset'
elif try_cmd(['convert'])[0]:
IMAGEMAGICK_BINARY = 'convert'
else:
IMAGEMAGICK_BINARY = 'unset'
else:
success, err = try_cmd([IMAGEMAGICK_BINARY])
if not success:
raise IOError(err.message +
"The path specified for the ImageMagick binary might be wrong")



Expand Down
2 changes: 1 addition & 1 deletion moviepy/config_defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@
"""

FFMPEG_BINARY = 'ffmpeg-imageio'
IMAGEMAGICK_BINARY = 'convert'
IMAGEMAGICK_BINARY = 'auto-detect'