@@ -450,6 +450,41 @@ def _args(self):
450450 self .fps )] + self .output_args
451451
452452
453+ # Base class for animated GIFs with convert utility
454+ class ImageMagickBase :
455+ exec_key = 'animation.convert_path'
456+ args_key = 'animation.convert_args'
457+
458+ @property
459+ def delay (self ):
460+ return 100. / self .fps
461+
462+ @property
463+ def output_args (self ):
464+ return [self .outfile ]
465+
466+
467+ @writers .register ('imagemagick' )
468+ class ImageMagickWriter (MovieWriter , ImageMagickBase ):
469+ def _args (self ):
470+ return ([self .bin_path (),
471+ '-size' , '%ix%i' % self .frame_size , '-depth' , '8' ,
472+ '-delay' , str (self .delay ), '-loop' , '0' ,
473+ '%s:-' % self .frame_format ]
474+ + self .output_args )
475+
476+
477+ @writers .register ('imagemagick_file' )
478+ class ImageMagickFileWriter (FileMovieWriter , ImageMagickBase ):
479+ supported_formats = ['png' , 'jpeg' , 'ppm' , 'tiff' , 'sgi' , 'bmp' ,
480+ 'pbm' , 'raw' , 'rgba' ]
481+
482+ def _args (self ):
483+ return ([self .bin_path (), '-delay' , str (self .delay ), '-loop' , '0' ,
484+ '%s*.%s' % (self .temp_prefix , self .frame_format )]
485+ + self .output_args )
486+
487+
453488class Animation (object ):
454489 '''
455490 This class wraps the creation of an animation using matplotlib. It is
@@ -512,7 +547,7 @@ def _stop(self, *args):
512547 self .event_source = None
513548
514549 def save (self , filename , writer = None , fps = None , dpi = None , codec = None ,
515- bitrate = None , extra_args = None , metadata = None , extra_anim = None ):
550+ bitrate = None , extra_args = None , metadata = None , extra_anim = None ):
516551 '''
517552 Saves a movie file by drawing every frame.
518553
0 commit comments