Skip to main content

A Sphinx extension to integrate Viewer.js for image zooming.

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jb1_zoomies-0.2.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jb1_zoomies-0.2-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file jb1_zoomies-0.2.tar.gz.

File metadata

  • Download URL: jb1_zoomies-0.2.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for jb1_zoomies-0.2.tar.gz
Algorithm Hash digest
SHA256 91a4ba5e80ac500eabd007c5f615e4a0d1cbb2d183f15790d13ecf806e9b2afb
MD5 b40fc92ab6e71dd1bd72b017117bde2a
BLAKE2b-256 8c7aa02daeaab0170160c0cbacb9a9750324b8ead9581a6e55248304f54045b6

See more details on using hashes here.

File details

Details for the file jb1_zoomies-0.2-py3-none-any.whl.

File metadata

  • Download URL: jb1_zoomies-0.2-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for jb1_zoomies-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 22138026accbf9ff6586b19725de6e4c23a4c5898f5a72873017875238aff012
MD5 f7d47179c38b5b929f1e0daa99cce726
BLAKE2b-256 994c802cb24064325f7d8d705939800368a8596e6aed582ee58de744df2f6300

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page