pictex
A Python library for efficient image generation using CSS Flexbox.
What it is and what it does
PicTex is a Python library that generates images by composing layout elements (Row, Column, Text, Image) using CSS Flexbox principles. You describe your visual design using familiar web layout properties like justify-content, align-items, and flex-grow, then render the result as a raster or vector image. It handles typography through HarfBuzz (supporting kerning, ligatures, and complex scripts), bidirectional text, gradients, shadows, and rounded borders—all without needing a browser or headless rendering infrastructure.
The library is built on industry-standard graphics engines: Skia for rendering, Taffy for layout computation, and HarfBuzz for text shaping. It's designed for automated image generation workflows like Open Graph previews, social media cards, video thumbnails, data visualizations, and report generation. If you know CSS, the API is intuitive; if you don't, the fluent method-chaining style makes styling declarative and readable.
Use it for:
- Generate Open Graph and social media preview images dynamically from metadata or API responses.
- Create styled code snippet images for tutorials, documentation, or social sharing.
- Build data visualization graphics (tables, charts) as PNG/SVG without a web rendering layer.
- Automate profile cards, GitHub repository cards, or tweet-like social graphics from structured data.
- Render multilingual or emoji-heavy text as images with proper shaping and bidirectional layout.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
PicTex generates high-quality PNG, JPEG, WebP, and SVG images programmatically using CSS Flexbox layouts, powered by Skia graphics rendering and HarfBuzz text shaping.
Yes, if you need programmatic image generation with CSS-like layout control and don't want browser overhead. The library is actively maintained, has no known vulnerabilities, uses a permissive license, and supports modern Python versions. Install friction is low. The main caveat: skia-python and uharfbuzz are compiled dependencies; verify prebuilt wheels are available for your platform before committing to the stack.
Install
pictex on PyPI
pip
pip install pictexuv
uv add pictexpoetry
poetry add pictexInstalling pictex
Before you install
Low friction: pure Python wheel with no compiled system dependencies beyond the runtime stack (skia-python, uharfbuzz). Active maintenance with last commit 2026-04-03 and 210 repository stars. Supports Python 3.9 through 3.13.
License in practice
MIT license (permissive): you can use, modify, and distribute PicTex freely in commercial and open-source projects with minimal restrictions.
Quickstart
pip install pictex
from pictex import Canvas, LinearGradient
canvas = Canvas().font_size(60).color("white").background_color(LinearGradient(["#2C3E50", "#FD746C"]))
image = canvas.render("Hello, World!")
image.save("output.png")
Requires Python 3.9 or later; skia-python and uharfbuzz are compiled dependencies that may require build tools on some systems.
Verify before relying
- Whether skia-python and uharfbuzz prebuilt wheels are available for all major platforms (Windows, macOS, Linux) without requiring compilation.
- Performance characteristics and memory footprint when rendering large or complex layouts.
- Exact SVG export capabilities and whether font embedding works reliably across all font types.
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 7 — importlib-resources, python-bidi, regex, skia-python, stretchable, typing-extensions, uharfbuzz |
| Maintenance | actively maintained — 133 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 84,165/month — #14,022 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pictex-2.3.0-py3-none-any.whl
Keywords: graphics, image-generation, skia, text-rendering, text-to-image, typography
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
stretchablestretchable is a Python layout engine that…
permissive · top 15,000 on PyPI
vtracerConverts raster images (JPG, PNG) into vector…
permissive · top 15,000 on PyPI
pdf417genEncodes text and binary data into PDF417 2D…
permissive · top 15,000 on PyPI
svg.pyGenerates SVG files programmatically in Python…
permissive · top 15,000 on PyPI
uharfbuzzCython bindings for HarfBuzz that shape text…
permissive · top 5,000 on PyPI
pansiPansi provides a clean interface for rendering…
permissive · top 15,000 on PyPI
rendercv-fontsProvides a collection of fonts packaged for use…
permissive · top 15,000 on PyPI
CairoSVGCairoSVG converts SVG files to PDF, EPS, PS,…
copyleft · top 5,000 on PyPI
PyQRCodePyQRCode generates QR codes in pure Python and…
permissive · top 15,000 on PyPI
sphinx_designA Sphinx extension that adds responsive web…
permissive · top 5,000 on PyPI