Skip to content

add gif support#865

Open
m-reuter wants to merge 1 commit intospatialaudio:masterfrom
m-reuter:gif
Open

add gif support#865
m-reuter wants to merge 1 commit intospatialaudio:masterfrom
m-reuter:gif

Conversation

@m-reuter
Copy link

@m-reuter m-reuter commented Feb 28, 2026

Add GIF Image Support to nbsphinx

Summary

This pull request adds support for rendering animated GIF images in Jupyter notebooks when using nbsphinx (see also #864 ). The implementation follows the same approach used in similar projects like WhipperSnapPy and the nbconvert PR for GIF support.
Note that we do not add a monkey patch for nbconvert here, so first the PR upstream needs to be merged before this will work.

Changes Made

1. Added image/gif to Display Data Priority (HTML)

  • File: src/nbsphinx/__init__.py
  • Change: Added 'image/gif' to the DISPLAY_DATA_PRIORITY_HTML tuple
  • Purpose: Ensures GIF images are considered as valid output types when rendering HTML output, with appropriate priority relative to other image formats

2. Added GIF File Extension Mapping

  • File: src/nbsphinx/__init__.py
  • Change: Added 'image/gif': '.gif' to the THUMBNAIL_MIME_TYPES dictionary
  • Purpose: Allows the system to correctly identify and use .gif file extensions when saving GIF images as thumbnails or standalone files

3. Updated RST Template for Image Directive

  • File: src/nbsphinx/__init__.py (RST_TEMPLATE)
  • Change: Added 'image/gif' to the image directive handling condition in the Jinja2 template
  • Purpose: Enables proper rendering of GIF images using reStructuredText's image directive

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant