Skip to main content

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

# 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


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.2.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

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

md2image-0.1.2-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file md2image-0.1.2.tar.gz.

File metadata

  • Download URL: md2image-0.1.2.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

Hashes for md2image-0.1.2.tar.gz
Algorithm Hash digest
SHA256 e29cfc719cb398b79c50d012d03fbb5db8a0fbd1528b088065ee799700a1eaa1
MD5 eaf5a12b5ae6048246bb3320fc172e7e
BLAKE2b-256 e9c5e433deb2b0f4767b11ebc975187a5191f56ab974df1bc9a65b2606470cc0

See more details on using hashes here.

File details

Details for the file md2image-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: md2image-0.1.2-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

Hashes for md2image-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e3b5be24f0a4b53bc3a4b147f691d314e8a6700670b16a1459b4ac97a3da9efa
MD5 570d74da00614bf6405a4e56d9b8bcf1
BLAKE2b-256 8c360a1438c9c17bb1ad6f628871a706622170152a3980880906fc21e4c75727

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