PicTex v1.0 is here: a declarative layout engine for creating images in Python
Hey r/Python,
A few weeks ago, I [posted](https://www.reddit.com/r/Python/comments/1lwjsar/pictex_a_python_library_to_easily_create_stylized/) about my personal project, `PicTex`, a library for making stylized text images. I'm really happy for all the feedback and suggestions I received.
It was a huge motivator and inspired me to take the project to the next level. I realized the core idea of a simple, declarative API could be applied to more than just a single block of text. So, `PicTex` has evolved. It's no longer just a "text-styler"; it's now a declarative UI-to-image layout engine.
You can still do simple, beautiful text banners easily:
```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")
```
Result: [https://imgur.com/a/Wp5TgGt](https://imgur.com/a/Wp5TgGt)
But now you can compose different components together. Instead of just rendering text, you can now build a whole tree of `Row`, `Column`, `Text`, and `Image` nodes.
Here's a card example:
```python
from pictex import *
# 1. Create the individual content builders
avatar
/r/Python
https://redd.it/1mhdbcf
Hey r/Python,
A few weeks ago, I [posted](https://www.reddit.com/r/Python/comments/1lwjsar/pictex_a_python_library_to_easily_create_stylized/) about my personal project, `PicTex`, a library for making stylized text images. I'm really happy for all the feedback and suggestions I received.
It was a huge motivator and inspired me to take the project to the next level. I realized the core idea of a simple, declarative API could be applied to more than just a single block of text. So, `PicTex` has evolved. It's no longer just a "text-styler"; it's now a declarative UI-to-image layout engine.
You can still do simple, beautiful text banners easily:
```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")
```
Result: [https://imgur.com/a/Wp5TgGt](https://imgur.com/a/Wp5TgGt)
But now you can compose different components together. Instead of just rendering text, you can now build a whole tree of `Row`, `Column`, `Text`, and `Image` nodes.
Here's a card example:
```python
from pictex import *
# 1. Create the individual content builders
avatar
/r/Python
https://redd.it/1mhdbcf
Reddit
From the Python community on Reddit: PicTex, a Python library to easily create stylized text images
Explore this post and more from the Python community