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 ,
@@ -551,6 +553,27 @@ def delay(self):
551
553
def output_args (self ):
552
554
return [self .outfile ]
553
555
556
+ @classmethod
557
+ def _init_from_registry (cls ):
558
+ if sys .platform != 'win32' or rcParams [cls .exec_key ] != 'convert' :
559
+ return
560
+ from matplotlib .externals .six .moves import winreg
561
+ for flag in (0 , winreg .KEY_WOW64_32KEY , winreg .KEY_WOW64_64KEY ):
562
+ try :
563
+ hkey = winreg .OpenKeyEx (winreg .HKEY_LOCAL_MACHINE ,
564
+ 'Software\\ Imagemagick\\ Current' ,
565
+ 0 , winreg .KEY_QUERY_VALUE | flag )
566
+ binpath = winreg .QueryValueEx (hkey , 'BinPath' )[0 ]
567
+ winreg .CloseKey (hkey )
568
+ binpath += '\\ convert.exe'
569
+ break
570
+ except Exception :
571
+ binpath = ''
572
+ rcParams [cls .exec_key ] = rcParamsDefault [cls .exec_key ] = binpath
573
+
574
+
575
+ ImageMagickBase ._init_from_registry ()
576
+
554
577
555
578
@writers .register ('imagemagick' )
556
579
class ImageMagickWriter (MovieWriter , ImageMagickBase ):
0 commit comments