Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jay3332/pilmoji
Pilmoji is a fast and reliable emoji renderer for PIL.
https://github.com/jay3332/pilmoji
emoji pil pillow python python3
Last synced: 7 days ago
JSON representation
Pilmoji is a fast and reliable emoji renderer for PIL.
- Host: GitHub
- URL: https://github.com/jay3332/pilmoji
- Owner: jay3332
- License: mit
- Created: 2021-05-13T23:42:05.000Z (over 3 years ago)
- Default Branch: 2.0
- Last Pushed: 2024-06-18T22:10:47.000Z (7 months ago)
- Last Synced: 2024-12-17T23:05:09.586Z (14 days ago)
- Topics: emoji, pil, pillow, python, python3
- Language: Python
- Homepage:
- Size: 53.7 KB
- Stars: 81
- Watchers: 2
- Forks: 29
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Pilmoji
Pilmoji is an emoji renderer for [Pillow](https://github.com/python-pillow/Pillow/),
Python's imaging library.Pilmoji comes equipped with support for both unicode emojis and Discord emojis.
## Features
- Discord emoji support
- Multi-line rendering support
- Emoji position and/or size adjusting
- Many built-in emoji sources
- Optional caching## Installation and Requirements
You must have Python 3.8 or higher in order to install Pilmoji.Installation can be done with `pip`:
```shell
$ pip install -U pilmoji
```Optionally, you can add the `[requests]` option to install requests
alongside Pilmoji:
```shell
$ pip install -U pilmoji[requests]
```The option is not required, instead if `requests` is not installed,
Pilmoji will fallback to use the builtin `urllib`.You may also install from Github.
## Usage
```py
from pilmoji import Pilmoji
from PIL import Image, ImageFontmy_string = '''
Hello, world! 👋 Here are some emojis: 🎨 🌊 😎
I also support Discord emoji: <:rooThink:596576798351949847>
'''with Image.new('RGB', (550, 80), (255, 255, 255)) as image:
font = ImageFont.truetype('arial.ttf', 24)with Pilmoji(image) as pilmoji:
pilmoji.text((10, 10), my_string.strip(), (0, 0, 0), font)image.show()
```#### Result
![Example result](https://jay.has-no-bra.in/f/j4iEcc.png)## Switching emoji sources
As seen from the example, Pilmoji defaults to the `Twemoji` emoji source.If you prefer emojis from a different source, for example Microsoft, simply
set the `source` kwarg in the constructor to a source found in the
`pilmoji.source` module:```py
from pilmoji.source import MicrosoftEmojiSourcewith Pilmoji(image, source=MicrosoftEmojiSource) as pilmoji:
...
```![results](https://jay.has-no-bra.in/f/suPfj0.png)
It is also possible to create your own emoji sources via subclass.
## Fine adjustments
If an emoji looks too small or too big, or out of place, you can make fine adjustments
with the `emoji_scale_factor` and `emoji_position_offset` kwargs:```py
pilmoji.text((10, 10), my_string.strip(), (0, 0, 0), font,
emoji_scale_factor=1.15, emoji_position_offset=(0, -2))
```## Contributing
Contributions are welcome. Make sure to follow [PEP-8](https://www.python.org/dev/peps/pep-0008/)
styling guidelines.