Skip to content
Closed
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
25 changes: 24 additions & 1 deletion lib/matplotlib/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from matplotlib.cbook import iterable, is_string_like
from matplotlib.compat import subprocess
from matplotlib import verbose
from matplotlib import rcParams
from matplotlib import rcParams, rcParamsDefault

# Process creation flag for subprocess to prevent it raising a terminal
# window. See for example:
Expand Down Expand Up @@ -262,6 +262,8 @@ def isAvailable(cls):
Check to see if a MovieWriter subclass is actually available by
running the commandline tool.
'''
if not cls.bin_path():
return False
try:
p = subprocess.Popen(cls.bin_path(),
shell=False,
Expand Down Expand Up @@ -545,6 +547,27 @@ def delay(self):
def output_args(self):
return [self.outfile]

@classmethod
def _init_from_registry(cls):
if sys.platform != 'win32' or rcParams[cls.exec_key] != 'convert':
return
from matplotlib.externals.six.moves import winreg
for flag in (0, winreg.KEY_WOW64_32KEY, winreg.KEY_WOW64_64KEY):
try:
hkey = winreg.OpenKeyEx(winreg.HKEY_LOCAL_MACHINE,
'Software\\Imagemagick\\Current',
0, winreg.KEY_QUERY_VALUE | flag)
binpath = winreg.QueryValueEx(hkey, 'BinPath')[0]
winreg.CloseKey(hkey)
binpath += '\\convert.exe'
break
except Exception:
binpath = ''
rcParams[cls.exec_key] = rcParamsDefault[cls.exec_key] = binpath


ImageMagickBase._init_from_registry()


@writers.register('imagemagick')
class ImageMagickWriter(MovieWriter, ImageMagickBase):
Expand Down