telegram-sticker-utils


Nametelegram-sticker-utils JSON
Version 0.2.16 PyPI version JSON
download
home_pageNone
Summaryeasy and fast processing of telegram stickers
upload_time2024-12-19 14:30:55
maintainerNone
docs_urlNone
authorNone
requires_python<3.13,>=3.9
licenseApache-2.0
keywords telegram sticker image video processing ffmpeg pillow
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # πŸ“¦ 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/0e/99/726a07f378d2f9af5d86cb9cd3cc629fe3568a283050ba4aed90ed18379b/telegram_sticker_utils-0.2.16.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.16",
    "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": "8729f998c19cf611a6e076ccc8ea1e44266c357ed8ce9578b7417119cc99f37c",
                "md5": "c5f14f9ac53e401befb0aec2f2f2ad67",
                "sha256": "48ab6b1d6ee9d9ae4b65c9ab73fd658691fcd9a599fc68506b2e14648b8329a5"
            },
            "downloads": -1,
            "filename": "telegram_sticker_utils-0.2.16-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c5f14f9ac53e401befb0aec2f2f2ad67",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<3.13,>=3.9",
            "size": 19691,
            "upload_time": "2024-12-19T14:30:53",
            "upload_time_iso_8601": "2024-12-19T14:30:53.729931Z",
            "url": "https://files.pythonhosted.org/packages/87/29/f998c19cf611a6e076ccc8ea1e44266c357ed8ce9578b7417119cc99f37c/telegram_sticker_utils-0.2.16-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0e99726a07f378d2f9af5d86cb9cd3cc629fe3568a283050ba4aed90ed18379b",
                "md5": "fa81c8816aa88d2d6c907c843c7ad7bc",
                "sha256": "4b9f0cfc4fa9dbf1b5b030c390c852f82017758cf9daf397765183f27dea120a"
            },
            "downloads": -1,
            "filename": "telegram_sticker_utils-0.2.16.tar.gz",
            "has_sig": false,
            "md5_digest": "fa81c8816aa88d2d6c907c843c7ad7bc",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<3.13,>=3.9",
            "size": 19509,
            "upload_time": "2024-12-19T14:30:55",
            "upload_time_iso_8601": "2024-12-19T14:30:55.938340Z",
            "url": "https://files.pythonhosted.org/packages/0e/99/726a07f378d2f9af5d86cb9cd3cc629fe3568a283050ba4aed90ed18379b/telegram_sticker_utils-0.2.16.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-19 14:30:55",
    "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"
}
        
Elapsed time: 0.40112s