pictex


Namepictex JSON
Version 1.2.1 PyPI version JSON
download
home_pageNone
SummaryA library to generate complex visual compositions and beautifully styled images.
upload_time2025-09-07 22:35:55
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseNone
keywords graphics image-generation skia text-rendering text-to-image typography
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PicTex

[![PyPI version](https://badge.fury.io/py/pictex.svg?v=4)](https://pypi.org/project/pictex/)
[![CI Status](https://github.com/francozanardi/pictex/actions/workflows/test.yml/badge.svg)](https://github.com/francozanardi/pictex/actions/workflows/test.yml)
[![Codecov](https://codecov.io/gh/francozanardi/pictex/branch/main/graph/badge.svg)](https://codecov.io/gh/francozanardi/pictex)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

A powerful Python library for creating complex visual compositions and beautifully styled images. Powered by Skia.

![PicTex](https://res.cloudinary.com/dlvnbnb9v/image/upload/v1753831765/readme-1_vqnohh.png)

**`PicTex`** is a component-based graphics library that makes it easy to generate dynamic images for social media, video overlays, and digital art. It abstracts away the complexity of graphics engines, offering a declarative and chainable interface inspired by modern layout systems.

## Features

-   **Component-Based Layout**: Compose complex visuals by nesting powerful layout primitives like `Row`, `Column`, and `Image`.
-   **Rich Styling**: Gradients, multiple shadows, borders with rounded corners, and text decorations.
-   **Advanced Typography**: Custom fonts, variable fonts, line height, and alignment.
-   **Automatic Font Fallback**: Seamlessly render emojis and multilingual text.
-   **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

```bash
pip install pictex
```

## Quickstart

### Styled text image

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

```python
from pictex import Canvas, Shadow, LinearGradient

# 1. Create a style template using the fluent API
canvas = (
    Canvas()
    .font_family("Poppins-Bold.ttf")
    .font_size(60)
    .color("white")
    .padding(20)
    .background_color(LinearGradient(["#2C3E50", "#FD746C"]))
    .border_radius(10)
    .text_shadows(Shadow(offset=(2, 2), blur_radius=3, color="black"))
)

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

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

![Quickstart result](https://res.cloudinary.com/dlvnbnb9v/image/upload/v1754103059/hello_zqkkba.png)

### Composed elements

Compose elements like `Row`, `Column`, and `Text` to build complex visuals. PicTex's fluent API makes styling declarative and intuitive.

```python
from pictex import *

# 1. Build your visual components
avatar = (
    Image("avatar.png")
    .border_radius("50%")
    .background_color("silver")
    .border(3, "white")
    .box_shadows(Shadow(offset=(2, 2), blur_radius=5, color="black"))
)

user_info = Column(
    Text("Alex Doe").font_size(24).font_weight(700).color("#184e77"),
    Text("Graphic Designer").color("#edf6f9").text_shadows(Shadow(offset=(1, 1), blur_radius=1, color="black")),
).horizontal_align("center").gap(4)

# 2. Compose them in a layout container
card = (
    Column(avatar, user_info)
    .background_color(LinearGradient(["#d9ed92", "#52b69a"]))
    .border_radius(20)
    .padding(30)
    .horizontal_align("center")
    .gap(20)
)

# 3. Render and save the final image
canvas = Canvas().font_family("NataSans.ttf")
image = canvas.render(card)
image.save("profile_card.png")
```

![Quickstart result](https://res.cloudinary.com/dlvnbnb9v/image/upload/v1754103067/profile_card_b7ofk7.png)

## More Examples

PicTex 1.0's layout engine unlocks a huge range of possibilities, from social media graphics to data visualizations. We've created a collection of ready-to-run examples to showcase what you can build.

| Preview                                                      | Description                                                                                                                                                                                                                    |
|:-------------------------------------------------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ![Tweet to Image Example](https://res.cloudinary.com/dlvnbnb9v/image/upload/v1754446864/tweet_ouzwyf.png)   | **Tweet to Image** <br/> Recreate the look and feel of a tweet, perfect for sharing on other social platforms. <br/> **[View Code »](https://github.com/francozanardi/pictex/blob/main/examples/tweet_card/tweet_card.py)**    |
| ![Data Table Example](https://res.cloudinary.com/dlvnbnb9v/image/upload/v1754446872/table_t8hoyi.png)            | **Data Table** <br/> Generate a clean, styled table from a 2D list. Includes headers, zebra-striping, and shadows. <br/> **[View Code »](https://github.com/francozanardi/pictex/blob/main/examples/table/table.py)**          |
| ![Code Snippet Example](https://res.cloudinary.com/dlvnbnb9v/image/upload/v1754446867/result_exfjqr.png) | **Code Snippet** <br/> Create beautifully syntax-highlighted images of your code snippets for tutorials or social media. <br/> **[View Code »](https://github.com/francozanardi/pictex/blob/main/examples/code_to_image/code_to_image.py)** |

Check out the full [examples](https://github.com/francozanardi/pictex/tree/main/examples) directory for more!

## 📚 Dive Deeper

For a complete guide on all features, from layout and the box model to advanced styling, check out our full documentation:

-   [**Getting Started**](https://pictex.readthedocs.io/en/latest/getting_started/)
-   [**Core Concepts**](https://pictex.readthedocs.io/en/latest/core_concepts/)
-   [**Styling Guide: The Box Model**](https://pictex.readthedocs.io/en/latest/box_model/)
-   [**Styling Guide: Colors & Gradients**](https://pictex.readthedocs.io/en/latest/colors/)
-   [**Styling Guide: Text & Fonts**](https://pictex.readthedocs.io/en/latest/text/)

## Contributing

Contributions, issues, and feature requests are welcome! Feel free to check the [issues page](https://github.com/francozanardi/pictex/issues).

## License

This project is licensed under the MIT License - see the [LICENSE](https://github.com/francozanardi/pictex/LICENSE) file for details.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pictex",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "graphics, image-generation, skia, text-rendering, text-to-image, typography",
    "author": null,
    "author_email": "Franco Zanardi <francozanardi97@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/c9/5d/5068bdae28a1f320b829958fb43f5b2b0360e49b598efa4c57fb84e71ea2/pictex-1.2.1.tar.gz",
    "platform": null,
    "description": "# PicTex\n\n[![PyPI version](https://badge.fury.io/py/pictex.svg?v=4)](https://pypi.org/project/pictex/)\n[![CI Status](https://github.com/francozanardi/pictex/actions/workflows/test.yml/badge.svg)](https://github.com/francozanardi/pictex/actions/workflows/test.yml)\n[![Codecov](https://codecov.io/gh/francozanardi/pictex/branch/main/graph/badge.svg)](https://codecov.io/gh/francozanardi/pictex)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nA powerful Python library for creating complex visual compositions and beautifully styled images. Powered by Skia.\n\n![PicTex](https://res.cloudinary.com/dlvnbnb9v/image/upload/v1753831765/readme-1_vqnohh.png)\n\n**`PicTex`** is a component-based graphics library that makes it easy to generate dynamic images for social media, video overlays, and digital art. It abstracts away the complexity of graphics engines, offering a declarative and chainable interface inspired by modern layout systems.\n\n## Features\n\n-   **Component-Based Layout**: Compose complex visuals by nesting powerful layout primitives like `Row`, `Column`, and `Image`.\n-   **Rich Styling**: Gradients, multiple shadows, borders with rounded corners, and text decorations.\n-   **Advanced Typography**: Custom fonts, variable fonts, line height, and alignment.\n-   **Automatic Font Fallback**: Seamlessly render emojis and multilingual text.\n-   **Flexible Output**: \n    -   **Raster**: Save as PNG/JPEG/WebP, or convert to NumPy/Pillow.\n    -   **Vector**: Export to a clean, scalable SVG file with font embedding.\n-   **High-Quality Rendering**: Powered by Google's Skia graphics engine.\n\n## Installation\n\n```bash\npip install pictex\n```\n\n## Quickstart\n\n### Styled text image\n\nCreating a stylized text image is as simple as building a `Canvas` and calling `.render()`.\n\n```python\nfrom pictex import Canvas, Shadow, LinearGradient\n\n# 1. Create a style template using the fluent API\ncanvas = (\n    Canvas()\n    .font_family(\"Poppins-Bold.ttf\")\n    .font_size(60)\n    .color(\"white\")\n    .padding(20)\n    .background_color(LinearGradient([\"#2C3E50\", \"#FD746C\"]))\n    .border_radius(10)\n    .text_shadows(Shadow(offset=(2, 2), blur_radius=3, color=\"black\"))\n)\n\n# 2. Render some text using the template\nimage = canvas.render(\"Hello, World! \ud83c\udfa8\u2728\")\n\n# 3. Save or show the result\nimage.save(\"hello.png\")\n```\n\n![Quickstart result](https://res.cloudinary.com/dlvnbnb9v/image/upload/v1754103059/hello_zqkkba.png)\n\n### Composed elements\n\nCompose elements like `Row`, `Column`, and `Text` to build complex visuals. PicTex's fluent API makes styling declarative and intuitive.\n\n```python\nfrom pictex import *\n\n# 1. Build your visual components\navatar = (\n    Image(\"avatar.png\")\n    .border_radius(\"50%\")\n    .background_color(\"silver\")\n    .border(3, \"white\")\n    .box_shadows(Shadow(offset=(2, 2), blur_radius=5, color=\"black\"))\n)\n\nuser_info = Column(\n    Text(\"Alex Doe\").font_size(24).font_weight(700).color(\"#184e77\"),\n    Text(\"Graphic Designer\").color(\"#edf6f9\").text_shadows(Shadow(offset=(1, 1), blur_radius=1, color=\"black\")),\n).horizontal_align(\"center\").gap(4)\n\n# 2. Compose them in a layout container\ncard = (\n    Column(avatar, user_info)\n    .background_color(LinearGradient([\"#d9ed92\", \"#52b69a\"]))\n    .border_radius(20)\n    .padding(30)\n    .horizontal_align(\"center\")\n    .gap(20)\n)\n\n# 3. Render and save the final image\ncanvas = Canvas().font_family(\"NataSans.ttf\")\nimage = canvas.render(card)\nimage.save(\"profile_card.png\")\n```\n\n![Quickstart result](https://res.cloudinary.com/dlvnbnb9v/image/upload/v1754103067/profile_card_b7ofk7.png)\n\n## More Examples\n\nPicTex 1.0's layout engine unlocks a huge range of possibilities, from social media graphics to data visualizations. We've created a collection of ready-to-run examples to showcase what you can build.\n\n| Preview                                                      | Description                                                                                                                                                                                                                    |\n|:-------------------------------------------------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ![Tweet to Image Example](https://res.cloudinary.com/dlvnbnb9v/image/upload/v1754446864/tweet_ouzwyf.png)   | **Tweet to Image** <br/> Recreate the look and feel of a tweet, perfect for sharing on other social platforms. <br/> **[View Code \u00bb](https://github.com/francozanardi/pictex/blob/main/examples/tweet_card/tweet_card.py)**    |\n| ![Data Table Example](https://res.cloudinary.com/dlvnbnb9v/image/upload/v1754446872/table_t8hoyi.png)            | **Data Table** <br/> Generate a clean, styled table from a 2D list. Includes headers, zebra-striping, and shadows. <br/> **[View Code \u00bb](https://github.com/francozanardi/pictex/blob/main/examples/table/table.py)**          |\n| ![Code Snippet Example](https://res.cloudinary.com/dlvnbnb9v/image/upload/v1754446867/result_exfjqr.png) | **Code Snippet** <br/> Create beautifully syntax-highlighted images of your code snippets for tutorials or social media. <br/> **[View Code \u00bb](https://github.com/francozanardi/pictex/blob/main/examples/code_to_image/code_to_image.py)** |\n\nCheck out the full [examples](https://github.com/francozanardi/pictex/tree/main/examples) directory for more!\n\n## \ud83d\udcda Dive Deeper\n\nFor a complete guide on all features, from layout and the box model to advanced styling, check out our full documentation:\n\n-   [**Getting Started**](https://pictex.readthedocs.io/en/latest/getting_started/)\n-   [**Core Concepts**](https://pictex.readthedocs.io/en/latest/core_concepts/)\n-   [**Styling Guide: The Box Model**](https://pictex.readthedocs.io/en/latest/box_model/)\n-   [**Styling Guide: Colors & Gradients**](https://pictex.readthedocs.io/en/latest/colors/)\n-   [**Styling Guide: Text & Fonts**](https://pictex.readthedocs.io/en/latest/text/)\n\n## Contributing\n\nContributions, issues, and feature requests are welcome! Feel free to check the [issues page](https://github.com/francozanardi/pictex/issues).\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](https://github.com/francozanardi/pictex/LICENSE) file for details.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A library to generate complex visual compositions and beautifully styled images.",
    "version": "1.2.1",
    "project_urls": {
        "Changelog": "https://github.com/francozanardi/pictex/releases",
        "Homepage": "https://github.com/francozanardi/pictex",
        "Issues": "https://github.com/francozanardi/pictex/issues",
        "Repository": "https://github.com/francozanardi/pictex"
    },
    "split_keywords": [
        "graphics",
        " image-generation",
        " skia",
        " text-rendering",
        " text-to-image",
        " typography"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "9bd3808446571f45c6ea21fdabf1a1d8e51cdd069d786f296093aa1b10b877a8",
                "md5": "abd9a50e0495b07fd9aef7e9b3d5f25c",
                "sha256": "44418ff71c8be451a3197f6f814114d1b614641b771ad4904144c34296101ab1"
            },
            "downloads": -1,
            "filename": "pictex-1.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "abd9a50e0495b07fd9aef7e9b3d5f25c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 63691,
            "upload_time": "2025-09-07T22:35:09",
            "upload_time_iso_8601": "2025-09-07T22:35:09.769130Z",
            "url": "https://files.pythonhosted.org/packages/9b/d3/808446571f45c6ea21fdabf1a1d8e51cdd069d786f296093aa1b10b877a8/pictex-1.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "c95d5068bdae28a1f320b829958fb43f5b2b0360e49b598efa4c57fb84e71ea2",
                "md5": "e7cf5c7aab7dcbeb2552337754033633",
                "sha256": "2eccc126388419a7ed7f16c86cd5a202e9a01909a8580859d8292fd372a21a82"
            },
            "downloads": -1,
            "filename": "pictex-1.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "e7cf5c7aab7dcbeb2552337754033633",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 6917506,
            "upload_time": "2025-09-07T22:35:55",
            "upload_time_iso_8601": "2025-09-07T22:35:55.056076Z",
            "url": "https://files.pythonhosted.org/packages/c9/5d/5068bdae28a1f320b829958fb43f5b2b0360e49b598efa4c57fb84e71ea2/pictex-1.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-09-07 22:35:55",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "francozanardi",
    "github_project": "pictex",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pictex"
}
        
Elapsed time: 1.81196s