Render Markdown/Image to PIL Images with flexible layout composition
Project description
md2img
Render Markdown or Image to PIL Images with flexible layout composition.
Features
- Render Markdown to PNG: headings, bold/italic, code blocks, lists, tables, blockquotes, links
- Compose multiple images horizontally or vertically with optional Markdown panels and description bars
- Three built-in themes:
default,dark,warm - Pure Python (PIL), no heavy dependencies
Install
pip install md2image
Requires Python 3.8+ and Pillow >= 9.0.
Quick Start
from md2image import render_md, compose_h, compose_v
# Pure Markdown rendering
img = render_md("# Hello\n\n**Bold** and *italic* text.", width=800, theme="dark")
img.save("output.png")
# Compose images horizontally with a Markdown header
from PIL import Image
imgs = [Image.new("RGB", (300, 200), c) for c in ["#4F46E5", "#059669", "#DC2626"]]
result = compose_h(imgs, top_md="# Experiment Results\nThree runs compared.", target_height=220)
result.save("comparison.png")
API
from md2image import render_md, compose_h, compose_v
# Render markdown string to image
render_md(markdown, width=800, theme="default", padding=40)
# Horizontal composition
compose_h(images, target_height=240, top_md=..., bottom_md=..., top_desc=..., bottom_desc=..., theme="default")
# Vertical composition
compose_v(images, target_width=440, left_md=..., right_md=..., md_panel_width=280, theme="default")
Themes: default | dark | warm
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
md2image-0.1.3.tar.gz
(12.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
md2image-0.1.3-py3-none-any.whl
(11.3 kB
view details)
File details
Details for the file md2image-0.1.3.tar.gz.
File metadata
- Download URL: md2image-0.1.3.tar.gz
- Upload date:
- Size: 12.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cfffb97b74928c8db66b9cd0c159fad0a864933273c10055302ddea0d54019b7
|
|
| MD5 |
f2d27777006b0a91331f5534a7d34b31
|
|
| BLAKE2b-256 |
f20dda82a5bc4e2baedd956d3dc753c3ff7e34c91bbeab247db88436d1de1c1d
|
File details
Details for the file md2image-0.1.3-py3-none-any.whl.
File metadata
- Download URL: md2image-0.1.3-py3-none-any.whl
- Upload date:
- Size: 11.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba237b089e5b0c05c7dc56ddf018592ab6e8cc276a804ba7e4dc7f1720f9e6f8
|
|
| MD5 |
8a49e833ab6bf9e72b0ef602f37eedf6
|
|
| BLAKE2b-256 |
70be82e008a70abd03b94b4c8fc94e96d61402573e7a1700d34e4614e3a7d660
|