# π¦ Telegram Sticker Utils SDK
[![PyPI version](https://badge.fury.io/py/telegram-sticker-utils.svg)](https://badge.fury.io/py/telegram-sticker-utils)
[![Downloads](https://pepy.tech/badge/telegram-sticker-utils)](https://pepy.tech/project/telegram-sticker-utils)
If you are not a developer, you can use the Telegram Sticker [CLI](https://github.com/sudoskys/tsticker) (developed by
this SDK) for
user-friendly operations.
This SDK provides a set of utilities for working with Telegram stickers.
- Convert image formats without losing transparency.
- Auto optimize output size for sticker, make it valid for Telegram.
- Auto-detect sticker type and emojis.
## π Supported Pack Types
- [x] Video Sticker
- [x] Static Sticker
- [ ] Animated Sticker(Tgs)
## π Installation
You need install **[ImageMagick](https://github.com/imagemagick/imagemagick)** and
**[ffmpeg](https://www.ffmpeg.org/download.html)** before using this SDK.
Install Guide: https://docs.wand-py.org/en/0.6.12/guide/install.html
```shell
apt install ffmpeg
pip3 install telegram-sticker-utils
```
## π Usage
```python
import emoji
from telegram_sticker_utils import ImageProcessor
from telegram_sticker_utils import is_animated_gif
from telegram_sticker_utils.core.const import add_emoji_rule
try:
add_emoji_rule("sad", "π’")
add_emoji_rule("happy", emoji.emojize(":smile:"))
except ValueError as e:
print("NOT emoji")
print(is_animated_gif('test.gif')) # Path to the image file or a file-like object.
for sticker_file in ["happy.webp", "sad.png", "ι«ε
΄.jpg", "ζ²δΌ€.gif"]:
sticker = ImageProcessor.make_sticker(
input_name=sticker_file,
input_data=open(sticker_file, 'rb').read(),
scale=512
)
print(sticker.sticker_type)
print(sticker.emojis)
with open(f"{sticker_file}.{sticker.file_extension}", 'wb') as f:
f.write(sticker.data)
```
Raw data
{
"_id": null,
"home_page": null,
"name": "telegram-sticker-utils",
"maintainer": null,
"docs_url": null,
"requires_python": "<3.13,>=3.9",
"maintainer_email": null,
"keywords": "telegram, sticker, image, video, processing, ffmpeg, pillow",
"author": null,
"author_email": "sudoskys <coldlando@hotmail.com>",
"download_url": "https://files.pythonhosted.org/packages/f4/a0/7ed1315a1b9d3a4d0d35e61b27ad0b9d8f1ba129e3fa30a6be5e2b9e270c/telegram_sticker_utils-0.2.15.tar.gz",
"platform": null,
"description": "# \ud83d\udce6 Telegram Sticker Utils SDK\n\n[![PyPI version](https://badge.fury.io/py/telegram-sticker-utils.svg)](https://badge.fury.io/py/telegram-sticker-utils)\n[![Downloads](https://pepy.tech/badge/telegram-sticker-utils)](https://pepy.tech/project/telegram-sticker-utils)\n\nIf you are not a developer, you can use the Telegram Sticker [CLI](https://github.com/sudoskys/tsticker) (developed by\nthis SDK) for\nuser-friendly operations.\n\nThis SDK provides a set of utilities for working with Telegram stickers.\n\n- Convert image formats without losing transparency.\n- Auto optimize output size for sticker, make it valid for Telegram.\n- Auto-detect sticker type and emojis.\n\n## \ud83d\udee0 Supported Pack Types\n\n- [x] Video Sticker\n- [x] Static Sticker\n- [ ] Animated Sticker(Tgs)\n\n## \ud83d\ude80 Installation\n\nYou need install **[ImageMagick](https://github.com/imagemagick/imagemagick)** and \n**[ffmpeg](https://www.ffmpeg.org/download.html)** before using this SDK.\n\nInstall Guide: https://docs.wand-py.org/en/0.6.12/guide/install.html\n\n```shell\napt install ffmpeg\npip3 install telegram-sticker-utils\n```\n\n## \ud83d\udcd6 Usage\n\n```python\nimport emoji\n\nfrom telegram_sticker_utils import ImageProcessor\nfrom telegram_sticker_utils import is_animated_gif\nfrom telegram_sticker_utils.core.const import add_emoji_rule\n\ntry:\n add_emoji_rule(\"sad\", \"\ud83d\ude22\")\n add_emoji_rule(\"happy\", emoji.emojize(\":smile:\"))\nexcept ValueError as e:\n print(\"NOT emoji\")\n\nprint(is_animated_gif('test.gif')) # Path to the image file or a file-like object.\n\nfor sticker_file in [\"happy.webp\", \"sad.png\", \"\u9ad8\u5174.jpg\", \"\u60b2\u4f24.gif\"]:\n sticker = ImageProcessor.make_sticker(\n input_name=sticker_file,\n input_data=open(sticker_file, 'rb').read(),\n scale=512\n )\n print(sticker.sticker_type)\n print(sticker.emojis)\n with open(f\"{sticker_file}.{sticker.file_extension}\", 'wb') as f:\n f.write(sticker.data)\n```",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "easy and fast processing of telegram stickers",
"version": "0.2.15",
"project_urls": {
"Repository": "https://github.com/sudoskys/telegram-sticker-utils"
},
"split_keywords": [
"telegram",
" sticker",
" image",
" video",
" processing",
" ffmpeg",
" pillow"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6fbe26a38a0ec3773c77b8b8a8a5c4d4d8dfc7798f15861333cca408ba7e98c3",
"md5": "b64347296d8238f2b4dce54ff615dac5",
"sha256": "8afb0072c33623d6d9bfa98180e7d658a2bfd371ad3cca58c9de0e61530a960d"
},
"downloads": -1,
"filename": "telegram_sticker_utils-0.2.15-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b64347296d8238f2b4dce54ff615dac5",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<3.13,>=3.9",
"size": 16141,
"upload_time": "2024-10-13T10:26:57",
"upload_time_iso_8601": "2024-10-13T10:26:57.627521Z",
"url": "https://files.pythonhosted.org/packages/6f/be/26a38a0ec3773c77b8b8a8a5c4d4d8dfc7798f15861333cca408ba7e98c3/telegram_sticker_utils-0.2.15-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f4a07ed1315a1b9d3a4d0d35e61b27ad0b9d8f1ba129e3fa30a6be5e2b9e270c",
"md5": "8515c188ec57caec4dd0383903f6a309",
"sha256": "a4d7bfe6ec00dbce9ac6d858e12fe9cc0b0a1c05f8103253435043b7697d9add"
},
"downloads": -1,
"filename": "telegram_sticker_utils-0.2.15.tar.gz",
"has_sig": false,
"md5_digest": "8515c188ec57caec4dd0383903f6a309",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<3.13,>=3.9",
"size": 15773,
"upload_time": "2024-10-13T10:26:58",
"upload_time_iso_8601": "2024-10-13T10:26:58.539725Z",
"url": "https://files.pythonhosted.org/packages/f4/a0/7ed1315a1b9d3a4d0d35e61b27ad0b9d8f1ba129e3fa30a6be5e2b9e270c/telegram_sticker_utils-0.2.15.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-13 10:26:58",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "sudoskys",
"github_project": "telegram-sticker-utils",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "telegram-sticker-utils"
}