Add text to images using emojis
Project description
pyemoji2
Add text and emojis to images with zero dependencies. 🚀✨
A high-performance Python library for rendering text and emojis onto images. Built with Cairo and Pango, bundled for absolute simplicity.
✨ Features
- 🎯 Zero System Dependencies - Everything bundled in the wheel
- 🚀 Native Speed - Written in C, wrapped in Python
- 🎨 Rich Text - Supports all system fonts and emojis
- 🖼️ Direct Memory Access - No Pillow required
- 📦 Cross-Platform - Linux (x86_64, i686), macOS (x86_64, arm64)
- 📱 Android/Termux - Build from source support
- 🔥 Lightweight - ~5-8MB wheels with all dependencies included
🚀 Installation
From PyPI (Recommended)
pip install pyemoji2
That's it! No system libraries, no build tools, no hassle.
From Source (For Development)
If building from source, you need:
Ubuntu/Debian:
sudo apt install libcairo2-dev libpango1.0-dev pkg-config
macOS:
brew install cairo pango pkg-config
Termux (Android):
pkg install python clang make pkg-config libcairo pango
Then install:
pip install .
🖥️ Platform Support
Supported Platforms (Pre-built Wheels)
- ✅ Linux - x86_64, i686 (manylinux2014)
- ✅ macOS - x86_64 (Intel), arm64 (Apple Silicon)
Build from Source
- ✅ Android/Termux - Full support with source build
- ⚠️ Windows - Not currently supported (Cairo/Pango dependency issues)
- ⚠️ Linux ARM64 - Build from source recommended
For unsupported platforms, you can build from source following the instructions above.
📖 Usage
Basic Example
import pyemoji2
# Create a blank canvas
editor = pyemoji2.EmojiEditor.create_empty(500, 300)
# Add text with emojis
editor.add_text("Hello World! 🌍", 50, 150, "Sans", 60, "black")
editor.add_text("Made with ❤️", 150, 250, "Sans", 30, "red")
# Save
editor.save("output.png")
Advanced Example
import pyemoji2
# Create image
editor = pyemoji2.EmojiEditor.create_empty(800, 400)
# Title
editor.add_text("🎉 pyemoji2", 50, 80, "Sans Bold", 72, "black")
# Subtitle
editor.add_text("Zero-dependency emoji rendering", 50, 150, "Sans", 36, "black")
# Features
editor.add_text("✅ Fast", 50, 220, "Sans", 28, "black")
editor.add_text("✅ Simple", 50, 270, "Sans", 28, "black")
editor.add_text("✅ Cross-platform", 50, 320, "Sans", 28, "black")
editor.save("demo.png")
API Reference
EmojiEditor.create_empty(width, height)
Create a blank ARGB32 image.
Parameters:
width(int): Image width in pixelsheight(int): Image height in pixels
Returns: EmojiEditor instance
editor.add_text(text, x, y, font_family, font_size, color)
Add text to the image.
Parameters:
text(str): Text to render (supports emojis)x(float): X coordinate (top-left)y(float): Y coordinate (top-left)font_family(str): Font name (e.g., "Sans", "Serif", "Monospace")font_size(float): Font size in pointscolor(str): Color name ("black", "red", etc.)
editor.save(output_path)
Save the image as PNG.
Parameters:
output_path(str): Output file path
🏗️ Development
Build Extension
python setup.py build_ext --inplace
Run Tests
python test_pyemoji2.py
📊 Performance
- Rendering Speed: ~1ms for typical text
- Memory: Minimal overhead, direct Cairo surfaces
- Wheel Size: 5-10MB (all dependencies included)
🤝 Contributing
Contributions welcome! Please open an issue or PR.
📄 License
MIT
🙏 Acknowledgments
Built with:
- Cairo - 2D graphics library
- Pango - Text layout engine
- cibuildwheel - Cross-platform wheel building
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyemoji2-0.1.0.tar.gz.
File metadata
- Download URL: pyemoji2-0.1.0.tar.gz
- Upload date:
- Size: 9.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ade01f10d767fe23cfa42e8a20102fc7aa8016b41c33ae0fc51ace253cbbf11e
|
|
| MD5 |
250921d280d3cdca48572bd6ce9cf079
|
|
| BLAKE2b-256 |
ef9bfc0dcaf82d0d1ad939670e0b081b9c4504bbb02ff68b03d6f3d4dda3d42d
|
File details
Details for the file pyemoji2-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pyemoji2-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 2.4 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dcf7237fcb57947e6e2a3a8c51fcb11057bc78359c7d1b691ac47d746ac3ed66
|
|
| MD5 |
0a7749755f6a727bca00be5d9f5b0d47
|
|
| BLAKE2b-256 |
31d752dda5d00631a8985dd1dbd0b196e1654fac60e88b9698179ce063ed22da
|
File details
Details for the file pyemoji2-0.1.0-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl.
File metadata
- Download URL: pyemoji2-0.1.0-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl
- Upload date:
- Size: 2.5 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
790ca4f2aed1c1b493afe885bd766f2184f1298a510e5bc7aff3cf71ab9dbd49
|
|
| MD5 |
9deda45009a4a702618c3705024d8e97
|
|
| BLAKE2b-256 |
c995ca9624327432a65b51d50331277c68898371a685d170a21fe524ed251546
|
File details
Details for the file pyemoji2-0.1.0-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: pyemoji2-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 4.2 MB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3061fc06de68c50f8ac44346c0c1827d6212c6d5854c4f1eb3aab9a4c1683466
|
|
| MD5 |
92dc99def41432f5cbca026e8ba40a92
|
|
| BLAKE2b-256 |
d5dc965586d2bc8dda9b83a7d6ab300cfcc5429fa494bf790d1802063dc39ced
|