Skip to content

aaichert/html_snippets

Repository files navigation

html_snippets

A Python package for generating interactive HTML snippets optimized for Jupyter notebooks and web applications.

Features

  • Interactive Tables: Sortable, searchable tables with color-coded data and fancy headers
  • Image Processing: Convert PIL images to HTML with thumbnails, scaling, and base64 encoding
  • Image Overlays: Create animated overlays with fade effects, hover interactions, and frame sequences
  • CSS/JS Animations: Frame-by-frame animations using pure CSS or JavaScript
  • Toggle Controls: Interactive visibility toggles with checkboxes and labels
  • Volume Visualization: Multiplanar 3D volume viewer with RGB channel controls
  • Layout Utilities: Horizontal layout containers and flexible UI components

Preview

preview.png

See example.ipynb for detailed usage examples.

Installation

From Source (Development)

git clone https://github.com/aaichert/html_snippets.git
cd html_snippets
pip install -e .

From PyPI (Coming Soon)

pip install html_snippets

With Jupyter Support

pip install html_snippets[jupyter]

Quick Start

from html_snippets import html_table, html_image, html_animation_css
from PIL import Image
import numpy as np

# Create an HTML table
data = [{'name': 'Item 1', 'value': 42}, {'name': 'Item 2', 'value': 37}]
head, body, tail = html_table(data)

# Convert PIL image to HTML
image = Image.open('example.jpg')
html_img = html_image(image)

# Create frame-by-frame animation
frames = ['<div>Frame 1</div>', '<div>Frame 2</div>']
css, html_anim = html_animation_css(frames, frame_duration_sec=1.0)

# Create 3D volume viewer (requires numpy)
volume = np.random.randint(0, 255, (50, 100, 100, 3), dtype=np.uint8)  # DHWC format
multiplanar_html = html_multiplanar(volume)

License

Licensed under Apache 2.0.

About

A Python package to generate html snippets for image overlays and sortable tables.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors