Skip to main content

A Bootstrap-like semantic wrapper for Python Pillow

Project description

PillowStrap

Bootstrap-like semantics for Python Image Generation.

PyPI version License: MIT

PillowStrap is a wrapper around the Python Pillow (PIL) library. It replaces imperative coordinate math (e.g., x=150, y=300) with declarative, web-like semantics (e.g., row, col-6, text-center, bg-primary).

Stop calculating pixels. Start building layouts.

🚀 Features

  • 12-Column Grid System: Just like Bootstrap, organize content into rows and columns.
  • Auto-Stacking Text: No more manual Y-coordinate tracking. Text blocks stack automatically like a Word document.
  • Smart Word Wrapping: Text automatically breaks to the next line if it exceeds the column width.
  • Image Fit Utilities: Easily place images with cover or contain logic.
  • Theming: Centralized control over colors, fonts, and spacing.

Installation

pip install pillowstrap

Quick Start

Create a dashboard.py file and run this code:

from pillowstrap import PillowStrap

# 1. Initialize Canvas (Width x Height)
app = PillowStrap(width=1200, height=800, bg="white")

# 2. Header Row (Height: 100px)
with app.row(height=100) as row:
    row.col(12, bg="primary").text("Monthly Report", color="white", size=50, align="center")

# 3. Content Row (Height: 500px)
with app.row(height=500) as row:
    
    # Left Column: Text (Spans 4 columns)
    ctx = row.col(4, bg="light")
    
    # Stacking Headers
    ctx.text("Executive Summary", size=30, weight="bold")
    ctx.text("Prepared by: Gemini", size=20, color="secondary")
    
    # Auto-Wrapping Body Text
    ctx.text(
        "PillowStrap handles long text automatically. "
        "You do not need to calculate line breaks manually. "
        "It respects the column width and padding.",
        size=24
    )

    # Right Column: Image (Spans 8 columns)
    # Places an image and crops it to fill the area
    row.col(8).img("charts.png", fit="cover")

# 4. Save
app.save("dashboard.png")

Configuration

You can customize the colors and fonts by modifying pillowstrap/theme.py inside the library or subclassing the instance (feature coming in v1.1).

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

pillowstrap-1.0.2.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

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

pillowstrap-1.0.2-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file pillowstrap-1.0.2.tar.gz.

File metadata

  • Download URL: pillowstrap-1.0.2.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for pillowstrap-1.0.2.tar.gz
Algorithm Hash digest
SHA256 a4d58096977ed4c52a11b5e00bb1c3d2f4f4f65bcb7e451728958ed386685448
MD5 e3e364d00bab0cc7b97043522d91d757
BLAKE2b-256 f4853a2f61960cbcdd3e97fcc9494330f1febf94838811e64933e95d36413f4f

See more details on using hashes here.

File details

Details for the file pillowstrap-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: pillowstrap-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for pillowstrap-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 71f21dcb8fb190f543ab25e6219bc4e04a777f65baf5de3d1854c97293e26ff6
MD5 e04fe95ec8f1db38c57e34dfa7f58edf
BLAKE2b-256 f1409cb69ce2c29e71915fbd062b20487b58fa14cc5d12a6d7d357a60d461b1c

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