Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Description
Summary
AFAICT, the output formats supported by the ImageMagick (IM) animation writers can essentially be split in two categories: GIF, and "true" movie formats (mp4, etc.). GIF output is currently also supported with no additional dependency (via Pillow, already a default dependency of Matplotlib), and output to "true" movie formats in IM appears to be done by piping out to ffmpeg (see WriteVideoImage in ImageMagick/coders/video.c), so there should be little advantage compared to directly using the FFMpeg animation writers (note that installing IM also results in a (private) copy of ffmpeg being installed on Windows).
On the other hand, supporting the IM writer means (admittedly not so often) working around bugs in IM itself (#18730), or limitations (#24268) or changes (#29567) in their CLI (the last issue being what triggered this idea). Therefore, I would suggest considering deprecating the IM writer and redirect its users to Pillow/FFMpeg (possibly adding a dispatch mechanism similar to backend_bases._default_backends to autoselect a writer that supports the requested format).
There is actually one specific advantage for the IM writer itself, which is the ability to optimize GIF output (https://usage.imagemagick.org/anim_opt/#optimize). However, I suspect this could be better provided as a separate post-process filtering option that allows calling e.g.magick mogrify -coalesce -layers OptimizePlus foo.gif
, which would have the advantage of being also applicable (I hope) to Pillow-generated GIFs.
For some more details, here's the list of multi-frame file formats that IM7.1.1-43 (last version as of today) can output, obtained withmagick identify -list format | grep 'w+'
:
Format list
``` Format Module Mode Description------------------------------------------------------------------------------- AAI* AAI rw+ AAI Dune image APNG VIDEO rw+ Animated Portable Network Graphics ASHLAR* ASHLAR -w+ Image sequence laid out in continuous irregular courses AVIF HEIC rw+ AV1 Image File Format (1.19.5) AVS* AVS rw+ AVS X image BAYER* BAYER rw+ Raw mosaiced samples BAYERA* BAYER rw+ Raw mosaiced and alpha samples BGR* BGR rw+ Raw blue, green, and red samples BGRA* BGR rw+ Raw blue, green, red, and alpha samples BGRO* BGR rw+ Raw blue, green, red, and opacity samples CLIP* CLIP rw+ Image Clip Mask CMYK* CMYK rw+ Raw cyan, magenta, yellow, and black samples CMYKA* CMYK rw+ Raw cyan, magenta, yellow, black, and alpha samples DATA* INLINE rw+ Base64-encoded inline images DCX* PCX rw+ ZSoft IBM PC multi-page Paintbrush DDS* DDS rw+ Microsoft DirectDraw Surface DXT1* DDS rw+ Microsoft DirectDraw Surface DXT5* DDS rw+ Microsoft DirectDraw Surface EPS3 PS3 -w+ Level III Encapsulated PostScript EPT3 EPT rw+ Encapsulated PostScript Level III with TIFF preview FAX* FAX rw+ Group 3 FAX FITS* FITS rw+ Flexible Image Transport System FLV VIDEO rw+ Flash Video Stream FTS* FITS rw+ Flexible Image Transport System GIF* GIF rw+ CompuServe graphics interchange format GRAY* GRAY rw+ Raw gray samples GRAYA* GRAY rw+ Raw gray and alpha samples HDR* HDR rw+ Radiance RGBE image format HEIC HEIC rw+ High Efficiency Image Format (1.19.5) HEIF HEIC rw+ High Efficiency Image Format (1.19.5) ICO* ICON rw+ Microsoft icon INFO INFO -w+ The image format and characteristics INLINE* INLINE rw+ Base64-encoded inline images IPL* IPL rw+ IPL Image Sequence JSON JSON -w+ The image format and characteristics JXL* JXL rw+ JPEG XL (ISO/IEC 18181) (libjxl 0.11.1) M2V VIDEO rw+ MPEG Video Stream M4V VIDEO rw+ Raw VIDEO-4 Video MASK* MASK rw+ Image Clip Mask MAT MAT rw+ MATLAB level 5 image format MATTE* MATTE -w+ MATTE format MIFF* MIFF rw+ Magick Image File Format MKV VIDEO rw+ Multimedia Container MNG* PNG rw+ Multiple-image Network Graphics (libpng 1.6.44,1.6.46) MOV VIDEO rw+ MPEG Video Stream MP4 VIDEO rw+ VIDEO-4 Video Stream MPC* MPC rw+ Magick Pixel Cache image format MPEG VIDEO rw+ MPEG Video Stream MPG VIDEO rw+ MPEG Video Stream MSL* MSL rw+ Magick Scripting Language MSVG* SVG rw+ ImageMagick's own SVG internal renderer MTV* MTV rw+ MTV Raytracing image format PALM* PALM rw+ Palm pixmap PAM* PNM rw+ Common 2-dimensional bitmap format PBM* PNM rw+ Portable bitmap format (black and white) PCL PCL rw+ Printer Control Language PDB* PDB rw+ Palm Database ImageViewer Format PDF PDF rw+ Portable Document Format PDFA PDF rw+ Portable Document Archive Format PFM* PNM rw+ Portable float format PGM* PNM rw+ Portable graymap format (gray scale) PHM* PNM rw+ Portable half float format PNM* PNM rw+ Portable anymapPOCKETMOD PDF rw+ Pocketmod Personal Organizer PPM* PNM rw+ Portable pixmap format (color) PS PS rw+ PostScript PS2 PS2 -w+ Level II PostScript PS3 PS3 -w+ Level III PostScript PSB* PSD rw+ Adobe Large Document Format PSD* PSD rw+ Adobe Photoshop bitmap PTIF* TIFF rw+ Pyramid encoded TIFF RAS* SUN rw+ SUN Rasterfile RGB* RGB rw+ Raw red, green, and blue samples RGBA* RGB rw+ Raw red, green, blue, and alpha samples RGBO* RGB rw+ Raw red, green, blue, and opacity samples SGI* SGI rw+ Irix RGB imageSPARSE-COLOR* TXT -w+ Sparse Color SUN* SUN rw+ SUN Rasterfile SVG* SVG rw+ Scalable Vector Graphics (XML 2.9.13) SVGZ* SVG rw+ Compressed Scalable Vector Graphics (XML 2.9.13)THUMBNAIL* THUMBNAIL -w+ EXIF Profile Thumbnail TIFF* TIFF rw+ Tagged Image File Format (LIBTIFF, Version 4.7.0) TIFF64* TIFF rw+ Tagged Image File Format (64-bit) (LIBTIFF, Version 4.7.0) TXT* TXT rw+ Text VID* VID rw+ Visual Image Directory VIFF* VIFF rw+ Khoros Visualization image VIPS* VIPS rw+ VIPS image WEBM VIDEO rw+ Open Web Media WEBP* WEBP rw+ WebP Image Format (libwebp 1.5.0 [0210]) WMV VIDEO rw+ Windows Media Video XV* VIFF rw+ Khoros Visualization image YAML YAML -w+ The image format and characteristics YCBCR* YCBCR rw+ Raw Y, Cb, and Cr samples YCBCRA* YCBCR rw+ Raw Y, Cb, Cr, and alpha samples```- formats using the VIDEO module, which rely on ffmpeg (we can directly call ffmpeg ourselves)
- other formats already supported by ffmpeg: AVIF,
- not real image formats: info, json, yaml, inline (base64), txt
- IM-specific formats: MIFF, MPC, MSL
- "raw samples", PNM, MAT, FAX (unlikely to be ever used for a Matplotlib animation)
- PDF, (E)PS, SVG(Z) (unlikely to be used as animations, and we have our own multipage writers anyways)
- APNG, GIF, ICO, TIFF, WebP (Pillow itself can write those, we should check whether PillowWriter actually works with them)
- FITS (unlikely to be ever used for a Matplotlib animation, and likely better served by Astropy's FITS support)
which leaves us with
AAI* AAI rw+ AAI Dune image ASHLAR* ASHLAR -w+ Image sequence laid out in continuous irregular courses AVS* AVS rw+ AVS X image CLIP* CLIP rw+ Image Clip Mask DCX* PCX rw+ ZSoft IBM PC multi-page Paintbrush DDS* DDS rw+ Microsoft DirectDraw Surface DXT1* DDS rw+ Microsoft DirectDraw Surface DXT5* DDS rw+ Microsoft DirectDraw Surface FAX* FAX rw+ Group 3 FAX HDR* HDR rw+ Radiance RGBE image format HEIC HEIC rw+ High Efficiency Image Format (1.19.5) HEIF HEIC rw+ High Efficiency Image Format (1.19.5) IPL* IPL rw+ IPL Image Sequence JXL* JXL rw+ JPEG XL (ISO/IEC 18181) (libjxl 0.11.1) MASK* MASK rw+ Image Clip Mask MNG* PNG rw+ Multiple-image Network Graphics (libpng 1.6.44,1.6.46) MTV* MTV rw+ MTV Raytracing image format PALM* PALM rw+ Palm pixmap PCL PCL rw+ Printer Control Language PDB* PDB rw+ Palm Database ImageViewer Format PSB* PSD rw+ Adobe Large Document Format PSD* PSD rw+ Adobe Photoshop bitmap RAS* SUN rw+ SUN Rasterfile SGI* SGI rw+ Irix RGB image SUN* SUN rw+ SUN RasterfileTHUMBNAIL* THUMBNAIL -w+ EXIF Profile Thumbnail VID* VID rw+ Visual Image Directory VIFF* VIFF rw+ Khoros Visualization image VIPS* VIPS rw+ VIPS image XV* VIFF rw+ Khoros Visualization image
I don't see anything among these which are really likely to be used as animation output formats either (exceptpossibly jxl and mng)?
Proposed fix
No response