|
38 | 38 | from matplotlib.cbook import iterable, is_string_like |
39 | 39 | from matplotlib.compat import subprocess |
40 | 40 | from matplotlib import verbose |
41 | | -from matplotlib import rcParams |
| 41 | +from matplotlib import rcParams, rcParamsDefault |
42 | 42 |
|
43 | 43 | # Process creation flag for subprocess to prevent it raising a terminal |
44 | 44 | # window. See for example: |
@@ -267,6 +267,8 @@ def isAvailable(cls): |
267 | 267 | Check to see if a MovieWriter subclass is actually available by |
268 | 268 | running the commandline tool. |
269 | 269 | ''' |
| 270 | + if not cls.bin_path(): |
| 271 | + return False |
270 | 272 | try: |
271 | 273 | p = subprocess.Popen(cls.bin_path(), |
272 | 274 | shell=False, |
@@ -550,6 +552,27 @@ def delay(self): |
550 | 552 | def output_args(self): |
551 | 553 | return [self.outfile] |
552 | 554 |
|
| 555 | + @classmethod |
| 556 | + def _init_from_registry(cls): |
| 557 | + if sys.platform != 'win32' or rcParams[cls.exec_key] != 'convert': |
| 558 | + return |
| 559 | + from matplotlib.externals.six.moves import winreg |
| 560 | + for flag in (0, winreg.KEY_WOW64_32KEY, winreg.KEY_WOW64_64KEY): |
| 561 | + try: |
| 562 | + hkey = winreg.OpenKeyEx(winreg.HKEY_LOCAL_MACHINE, |
| 563 | + 'Software\\Imagemagick\\Current', |
| 564 | + 0, winreg.KEY_QUERY_VALUE | flag) |
| 565 | + binpath = winreg.QueryValueEx(hkey, 'BinPath')[0] |
| 566 | + winreg.CloseKey(hkey) |
| 567 | + binpath += '\\convert.exe' |
| 568 | + break |
| 569 | + except Exception: |
| 570 | + binpath = '' |
| 571 | + rcParams[cls.exec_key] = rcParamsDefault[cls.exec_key] = binpath |
| 572 | + |
| 573 | + |
| 574 | +ImageMagickBase._init_from_registry() |
| 575 | + |
553 | 576 |
|
554 | 577 | @writers.register('imagemagick') |
555 | 578 | class ImageMagickWriter(MovieWriter, ImageMagickBase): |
|
0 commit comments