Moimage
A modern image widget for Jupyter notebooks and Python environments.
Installation
Using UV (recommended):
uv add moimage
Or using pip:
pip install moimage
Development Setup
- Clone the repository:
git clone <repository-url>
cd moimage
- Install with UV:
uv sync --dev
- Install in development mode:
uv pip install -e .
Usage
Basic Image Display
from moimage import ImageWidget
from PIL import Image
# Load image from file path
widget = ImageWidget("path/to/image.jpg")
display(widget)
# Load image from URL
widget = ImageWidget("https://example.com/image.png")
display(widget)
# Load from PIL Image object
pil_img = Image.open("image.jpg")
widget = ImageWidget(pil_img)
display(widget)
# Get image information
info = widget.get_image_info()
print(f"Image size: {info['width']}x{info['height']}")
Image Processing with Modular Widgets
from moimage import ImageOutlineWidget, ImageDownloadWidget, ImageClipboardWidget
# Create outline widget
outline_widget = ImageOutlineWidget(
"https://example.com/image.jpg",
outline_width=10,
outline_color="#FF0000"
)
# Create utility widgets that automatically sync
download_widget = ImageDownloadWidget(
image_src=outline_widget.processed_image_src,
filename="outlined_image",
format="png"
)
clipboard_widget = ImageClipboardWidget(
image_src=outline_widget.processed_image_src
)
# In Marimo, these widgets automatically react to changes!
Complete Marimo Example
import marimo as mo
from moimage import ImageOutlineWidget, ImageDownloadWidget, ImageClipboardWidget
# Create widgets
outline = mo.ui.anywidget(ImageOutlineWidget("image.jpg"))
download = mo.ui.anywidget(ImageDownloadWidget(
image_src=outline.value.processed_image_src
))
clipboard = mo.ui.anywidget(ImageClipboardWidget(
image_src=outline.value.processed_image_src
))
# Display widgets - they automatically sync through Marimo's reactivity!
mo.hstack([outline, mo.vstack([download, clipboard])])
Available Widgets
Core Widget
- ImageWidget: Display images with metadata information
- Supports file paths, URLs, and PIL Image objects
- Shows image dimensions, format, and source type
- Automatic base64 encoding for local files
- Error handling for invalid images
Processing Widgets
- ImageOutlineWidget: Apply outline/glow effects around image shapes
- Creates outline effects around non-transparent pixels (perfect for PNGs)
- Configurable outline width (1-50px) and color
- Canvas-based processing with alpha channel detection
- Inherits from ImageWidget for full image loading capabilities
- Reset functionality to return to original image
Utility Widgets
-
ImageDownloadWidget: Download images from any source
- Configurable filename and format (PNG, JPG, WebP)
- Works with base64 data URLs and remote URLs
- Cross-origin image handling with canvas conversion
- Clean, simple interface
-
ImageClipboardWidget: Copy images to system clipboard
- Modern Clipboard API with fallback support
- Handles base64 and remote images automatically
- Visual feedback and error handling
- Cross-browser compatibility
Features
- Built on AnyWidget framework for seamless Jupyter integration
- Modern JavaScript/HTML frontend with Python backend
- Reactive state management with traitlets
- Extensible architecture for custom widgets
- TypeScript support for frontend development
Creating Custom Widgets
import anywidget
import traitlets
class MyCustomWidget(anywidget.AnyWidget):
_esm = """
function render({ model, el }) {
// Your JavaScript rendering logic here
let value = model.get("value");
// ... create DOM elements and event handlers
}
export default { render };
"""
value = traitlets.Unicode("").tag(sync=True)
License
MIT License
Metadata
Release files for moimage 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| moimage-0.1.0.tar.gz | 17.8 kB | Without provenance | Details for moimage-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| moimage-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for moimage-0.1.0-py3-none-any.whl |
Total release size: 55.1 kB
Release files / moimage-0.1.0.tar.gz
| Download URL | moimage-0.1.0.tar.gz |
|---|---|
| Size | 17.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4b3280ce1f26473e7549cde2e4774ea370536b03c2377de5f65d9611ad01c7a5
|
|
BLAKE2b-256 checksum How to use checksums |
235bf2c6735fd9ab1dd096c948deac9604a95fd174fe6fc37c05c621148200cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.6
|
Release files / moimage-0.1.0-py3-none-any.whl
| Download URL | moimage-0.1.0-py3-none-any.whl |
|---|---|
| Size | 37.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
32523aad77d568fbddfed1ac5d146f1986e2530278ba3122f9dda036e98a9932
|
|
BLAKE2b-256 checksum How to use checksums |
d294b247544c5737fc6f6c3c19073d5697a894fc830f9259184918111ed08d3f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.6
|
Security for moimage 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.