Archived
This project has been archived by its maintainers, and is no longer receiving any updates.
JB1 Zoomies
A simple Sphinx extension to integrate Viewer.js for image zooming in Jupyter Books and Sphinx documentation.
Features
- Pinch & Zoom: Smooth, mobile-friendly zooming for all your images.
- Theme Integrated: Automatically adapts to light and dark modes, using your theme's native colors.
- Smart Captions: Automatically pulls captions from
<figure>elements to display them in the viewer. - Best-Fit Logic: Intelligently scales images to fit your viewport (configurable).
- Dark Mode Optimization: Option to automatically invert image colors in dark mode—perfect for scientific plots with white backgrounds.
- Customizable Toolbar: Choose exactly which tools (zoom, rotate, reset) are available to your readers.
Installation
pip install jb1-zoomies
Or from source:
pip install .
Usage
Jupyter Book
Add the extension to your _config.yml:
sphinx:
extra_extensions:
- jb1_zoomies
Sphinx
Add the extension to your conf.py:
extensions = [
# ...
'jb1_zoomies',
]
Configuration
JB1 Zoomies works out-of-the-box with PyData-based themes (like the Jupyter Book default), but you can fully customize it in your _config.yml (Jupyter Book) or conf.py (Sphinx).
Options
| Option | Default | Description |
|---|---|---|
zoomies_selector |
".bd-article img" |
CSS selector for images that should be zoomable. |
zoomies_best_fit |
70 |
Initial zoom level as a % of the viewport (1-100). |
zoomies_toolbar |
["zoomIn", ...] |
Tools to show. Options: zoomIn, zoomOut, oneToOne, reset, prev, play, next, rotateLeft, rotateRight, flipHorizontal, flipVertical. |
zoomies_invert_colors |
true |
Inverts image colors in dark mode. Useful for charts with white backgrounds. |
zoomies_bg_apply_to_img |
true |
If true, adds a background/padding directly to the image. If false, colors the entire backdrop. |
zoomies_bg_color_light |
"rgba(255, 255, 255, 0.95)" |
Viewer background color in light mode. |
zoomies_bg_color_dark |
"#333" |
Viewer background color in dark mode. |
zoomies_caption_color_light |
"var(--pst-color-text-base)" |
Caption text color in light mode. |
zoomies_caption_color_dark |
"var(--pst-color-text-base)" |
Caption text color in dark mode. |
zoomies_cdn_css |
"...viewer.min.css" |
URL for the Viewer.js CSS file. |
zoomies_cdn_js |
"...viewer.min.js" |
URL for the Viewer.js JS file. |
Example _config.yml (Jupyter Book)
sphinx:
config:
zoomies_selector: ".bd-article img, .my-custom-image-class"
zoomies_best_fit: 85
zoomies_toolbar: ["zoomIn", "zoomOut", "reset", "rotateRight"]
zoomies_invert_colors: false # Disable if your images are already dark-mode friendly
Example conf.py (Sphinx)
zoomies_selector = ".bd-article img"
zoomies_best_fit = 80
zoomies_invert_colors = True
Release files for jb1-zoomies 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| jb1_zoomies-0.2.1.tar.gz | 7.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| jb1_zoomies-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.3 kB
Release files / jb1_zoomies-0.2.1.tar.gz
| Download URL | jb1_zoomies-0.2.1.tar.gz |
|---|---|
| Size | 7.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
025c8bd87af0b04ec0cb380a4ab949248b9620e448cfcc30a4605d4e34507eb3
|
|
BLAKE2b-256 checksum How to use checksums |
11f13593142a86a6d8d98d6199cefa7d73ff3f96a1569da51cc5c249091cc161
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Release files / jb1_zoomies-0.2.1-py3-none-any.whl
| Download URL | jb1_zoomies-0.2.1-py3-none-any.whl |
|---|---|
| Size | 7.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
21eac1108ac0d190806d8fddc709948cd87acc74e0148d53002e2798a74b9aa3
|
|
BLAKE2b-256 checksum How to use checksums |
349cacd4cda4ce03f13c5fba5750ef6b7f6e364414f35635a24022bef7f6a1cd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|