skillfed

pictex

A Python library for efficient image generation using CSS Flexbox.

pictex v2.3.0 84.2K downloads/30d#14,022 on PyPI210
Permissive license Active released

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 pictex

uv

uv add pictex

poetry

poetry add pictex

Installing 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

Development Status :: 4 - BetaIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseNatural Language :: EnglishOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9Topic :: Multimedia :: GraphicsTopic :: Scientific/Engineering :: VisualizationTopic :: Software Development :: Libraries :: Python ModulesTopic :: Text Processing :: FontsTyping :: Typed

Tags

css flexbox image generationprogrammatic graphic design pythontext to image renderingsocial media card generatorlayout-based image creation
image-generationlayout-enginetypography

More Python Modules packages