Skip to main content

Pilmoji for nonebot-plugin-parser

Project description

Pilmoji

Pilmoji is an emoji renderer for 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:

$ pip install -U pilmoji

Optionally, you can add the [requests] option to install requests alongside Pilmoji:

$ 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

from pilmoji import Pilmoji
from PIL import Image, ImageFont


my_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

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:

from pilmoji.source import MicrosoftEmojiSource

with Pilmoji(image, source=MicrosoftEmojiSource) as pilmoji:
    ...

results

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:

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 styling guidelines.

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

pilmoji_for_parser-0.1.0.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

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

pilmoji_for_parser-0.1.0-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file pilmoji_for_parser-0.1.0.tar.gz.

File metadata

  • Download URL: pilmoji_for_parser-0.1.0.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pilmoji_for_parser-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9c94b6f8c20c14407da7f3d326a99e394cdd3cdcb503820decd6b2f1c0c5f97b
MD5 75671e3189ae0c4675230ed9aff46d48
BLAKE2b-256 1c44f4ed5df26ea758ad7d5d311be8ec3ba462f03a0d36f7bb0262e8c87a13b7

See more details on using hashes here.

Provenance

The following attestation bundles were made for pilmoji_for_parser-0.1.0.tar.gz:

Publisher: release.yml on fllesser/pilmoji-for-parser

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pilmoji_for_parser-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pilmoji_for_parser-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e7d1038fc864d0fd206d25dbda03e14c9ac1b8574ff55d649dc9dd68a20c9898
MD5 965805c58c9a9155f1e4131bdd4521d1
BLAKE2b-256 584b63d6531863caeb64ead3c4e6c4fc9d2240d2f10beba803e633eea0fbc657

See more details on using hashes here.

Provenance

The following attestation bundles were made for pilmoji_for_parser-0.1.0-py3-none-any.whl:

Publisher: release.yml on fllesser/pilmoji-for-parser

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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