You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

pictex

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pictex

A library to generate stylized text images.

0.3.0
pipPyPI
Maintainers
1

PicTex

PyPI version CI Status Codecov License: MIT

A powerful Python library to create beautifully styled text images with a simple, fluent API. Powered by Skia.

PicTex

PicTex makes it easy to generate styled text images for social media, video overlays, digital art, or any application where stylized text is needed. It abstracts away the complexity of graphics libraries, offering a declarative and chainable interface inspired by CSS.

Features

  • Fluent & Reusable API: Build styles declaratively and reuse them.
  • Rich Styling: Gradients, multiple shadows, outlines, and text decorations.
  • Advanced Typography: Custom fonts, variable fonts, line height, and alignment.
  • Automatic Font Fallback: Seamlessly render emojis and special characters even if your main font doesn't support them.
  • Flexible Output:
    • Raster: Save as PNG/JPEG/WebP, or convert to NumPy/Pillow.
    • Vector: Export to a clean, scalable SVG file with font embedding.
  • High-Quality Rendering: Powered by Google's Skia graphics engine.

Installation

pip install pictex

Quickstart

Creating a stylized text image is as simple as building a Canvas and calling .render().

from pictex import Canvas

# 1. Create a style template using the fluent API
canvas = (
    Canvas()
    .font_family("path/to/font.ttf")
    .font_size(60)
    .color("white")
    .padding(20)
    .background_color(LinearGradient(["#2C3E50", "#FD746C"]))
    .background_radius(10)
    .add_shadow(offset=(2, 2), blur_radius=3, color="black")
)

# 2. Render some text using the template
image = canvas.render("Hello, PicTex! 🎨✨")

# 3. Save or show the result
image.save("hello.png")

Quickstart result

You can also render it as SVG using Canvas.render_as_svg().

image = canvas.render_as_svg("Hello, PicTex! 🎨✨")
image.save("hello.svg")

Quickstart SVG result

📚 Dive Deeper

For a complete guide on all features, including text decorations, advanced gradients, smart cropping, and more, check out our full documentation:

Contributing

Contributions, issues, and feature requests are welcome! Feel free to check the issues page.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Keywords

graphics

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts