I was wondering if we could add "webp" to the list of known image extensions that scrapers may produce. The change would be a one-liner in:
|
_KNOWN_IMG_EXTS = ('png', 'svg', 'jpg', 'gif') |
which would have to be changed to:
_KNOWN_IMG_EXTS = ('png', 'svg', 'jpg', 'gif', 'webp')
The background for this is that I have recently built a custom scraper for the gallery of a rendering engine. This works great, but now I would like to add animations to some of the examples. Technically, GIF could work but the limitation of 256 colors really shows when you have complex shadows or gradients and that may send the wrong message with respect to the project's rendering capabilities. (It's wgpu/vulkan based, so it has all the bells and whistles and 265 colors don't do this justice.)
WEBP would be a nice alternative here, because it, too, has wide browser support, better compression than GIF and - most importantly - uses YUV420 instead of 8-bit palette RGB as a colorspace. The only thing "preventing" me from using it is sphinx-gallery, which currently hardcodes supported file extensions...
As a current workaround I am monkey-patching _KNOWN_IMG_EXTS in the _get_sg_image_scraper like so:
def _get_sg_image_scraper():
# hack webp as supported extension
import sphinx_gallery.scrapers
sphinx_gallery.scrapers._KNOWN_IMG_EXTS += ("webp",)
...
This works, but it would be much nicer if I wouldn't have to rely on a hack that modifies private variables from an upstream project.
I was wondering if we could add "webp" to the list of known image extensions that scrapers may produce. The change would be a one-liner in:
sphinx-gallery/sphinx_gallery/scrapers.py
Line 339 in e2ecb35
which would have to be changed to:
The background for this is that I have recently built a custom scraper for the gallery of a rendering engine. This works great, but now I would like to add animations to some of the examples. Technically, GIF could work but the limitation of 256 colors really shows when you have complex shadows or gradients and that may send the wrong message with respect to the project's rendering capabilities. (It's wgpu/vulkan based, so it has all the bells and whistles and 265 colors don't do this justice.)
WEBP would be a nice alternative here, because it, too, has wide browser support, better compression than GIF and - most importantly - uses YUV420 instead of 8-bit palette RGB as a colorspace. The only thing "preventing" me from using it is sphinx-gallery, which currently hardcodes supported file extensions...
As a current workaround I am monkey-patching
_KNOWN_IMG_EXTSin the_get_sg_image_scraperlike so:This works, but it would be much nicer if I wouldn't have to rely on a hack that modifies private variables from an upstream project.