Skip to main content

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 pixels
  • height (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 points
  • color (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:

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

pyemoji2-0.1.1.tar.gz (9.1 kB view details)

Uploaded Source

Built Distributions

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

pyemoji2-0.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

pyemoji2-0.1.1-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl (2.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ i686

pyemoji2-0.1.1-cp312-cp312-macosx_11_0_arm64.whl (4.2 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

File details

Details for the file pyemoji2-0.1.1.tar.gz.

File metadata

  • Download URL: pyemoji2-0.1.1.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyemoji2-0.1.1.tar.gz
Algorithm Hash digest
SHA256 4460b7d181920c71442754027838e8af7a2ed29cfdd5ae10386383808b7fad9f
MD5 c9729d9d1dd8ceb6f4fba95a7ecc58a2
BLAKE2b-256 7dc6b3e0038251066a14e15732dab872f13e5c8f09fb68b7bed6f766e6c78059

See more details on using hashes here.

File details

Details for the file pyemoji2-0.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyemoji2-0.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7898ea1eed0e8a2d720a27bd5bd2ec73dc633422a9831e73b1929c3a7f1a375b
MD5 b891d3e7d964f2ed3c76cb77896c026a
BLAKE2b-256 e0b85238d8758274a68ed364cc7a17e6b5f677a86b58a7802ce91a4b32d28c8f

See more details on using hashes here.

File details

Details for the file pyemoji2-0.1.1-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for pyemoji2-0.1.1-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 3771887b9dfa1fac91280185cbbc71445190f7bc0b126467a44786c62502952d
MD5 619aacc69af47b415a49a3b7b73b7654
BLAKE2b-256 0b61136326554db966677e559177e20b04fca6ff286efb22806a4ee0aa631996

See more details on using hashes here.

File details

Details for the file pyemoji2-0.1.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyemoji2-0.1.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4bada1ef10f204a5524dd7660b7c2f3ed27df360e177747f1ec6773c36ee5c20
MD5 373109cec69b2ba7086b13bf1269dd80
BLAKE2b-256 1df08461b0468362fab5f09d4d892a9fd234388e4cdc258f15e4e5a8b89a93aa

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