{"id":18030316,"url":"https://github.com/laggykiller/rlottie-python","last_synced_at":"2025-08-27T15:12:34.573Z","repository":{"id":65528180,"uuid":"585960967","full_name":"laggykiller/rlottie-python","owner":"laggykiller","description":"A ctypes API for rlottie, with additional functions for getting Pillow Image.","archived":false,"fork":false,"pushed_at":"2025-04-11T06:37:34.000Z","size":154,"stargazers_count":21,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-11T09:24:19.927Z","etag":null,"topics":["ctypes","ctypes-bindings","ctypes-wrapper","lottie","pillow","python","rlottie","telegram-sticker","telegram-stickers","tgs"],"latest_commit_sha":null,"homepage":"https://rlottie-python.readthedocs.io/en/latest/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/laggykiller.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"laggykiller"}},"created_at":"2023-01-06T15:04:01.000Z","updated_at":"2025-04-11T06:37:19.000Z","dependencies_parsed_at":"2024-06-10T11:04:27.290Z","dependency_job_id":null,"html_url":"https://github.com/laggykiller/rlottie-python","commit_stats":{"total_commits":34,"total_committers":2,"mean_commits":17.0,"dds":0.2647058823529411,"last_synced_commit":"9716ab6339e381222f0f6adcd7be63704e3a8a0d"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laggykiller%2Frlottie-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laggykiller%2Frlottie-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laggykiller%2Frlottie-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laggykiller%2Frlottie-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/laggykiller","download_url":"https://codeload.github.com/laggykiller/rlottie-python/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laggykiller%2Frlottie-python/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259280711,"owners_count":22833434,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ctypes","ctypes-bindings","ctypes-wrapper","lottie","pillow","python","rlottie","telegram-sticker","telegram-stickers","tgs"],"created_at":"2024-10-30T09:14:01.456Z","updated_at":"2025-06-26T16:33:54.423Z","avatar_url":"https://github.com/laggykiller.png","language":"Python","readme":"# rlottie-python\n\nA ctypes API for rlottie, with additional functions for getting Pillow Image and animated sequences, as well as telegram animated stickers (tgs).\n\nSee example/example.py for example usage.\n\nThe functions mostly follow [rlottie/inc/rlottie_capi.h](https://github.com/Samsung/rlottie/blob/master/inc/rlottie_capi.h)\n\nDocumentations: https://rlottie-python.readthedocs.io/en/latest/\n\n## Table of contents\n- [Installing](#installing)\n- [Building from source](#building-from-source)\n- [Examples](#examples)\n- [Comparing to other library](#comparing-to-other-library)\n- [Credits](#credits)\n\n## Installing\n\nNote that rlottie is included in the wheel package, you need not install librlottie.\n\nTo install, run the following:\n```bash\npip3 install rlottie-python\n```\n\n`Pillow` is optional dependency. It is required for `render_pillow_frame()`,\n`save_frame()` and `save_animation()`. To also install Pillow, run:\n```bash\npip3 install rlottie-python[full]\n```\n\n## Examples\nGetting information about an lottie animation\n```python\nfrom rlottie_python import LottieAnimation\n\nanim = LottieAnimation.from_file(\"samples/sample.json\")\nframes = anim.lottie_animation_get_totalframe()\nprint(f\"{frames = }\")\n\nwidth, height = anim.lottie_animation_get_size()\nprint(f\"{width, height = }\")\n\nduration = anim.lottie_animation_get_duration()\nprint(f\"{duration = }\")\n\ntotalframe = anim.lottie_animation_get_totalframe()\nprint(f\"{totalframe = }\")\n\nframerate = anim.lottie_animation_get_framerate()\nprint(f\"{framerate = }\")\n\nrender_tree = anim.lottie_animation_render_tree(0)\nprint(f\"{render_tree.mMaskList.size = }\")\n\nmapped_frame = anim.lottie_animation_get_frame_at_pos(0)\nprint(f\"{mapped_frame = }\")\n```\n\nRendering and saving frame\n```python\nfrom rlottie_python import LottieAnimation\nfrom PIL import Image\n\nanim = LottieAnimation.from_file(\"samples/sample.json\")\n\n# Method 1: Saving the frame to file directly\nanim.save_frame(\"frame30.png\", frame_num=30)\n\n# Method 2: Getting Pillow Image\nim = anim.render_pillow_frame(frame_num=40)\nim.save(\"frame40.png\")\n\n# Method 3: Getting buffer\nbuffer = anim.lottie_animation_render(frame_num=50)\nwidth, height = anim.lottie_animation_get_size()\nim = Image.frombuffer(\"RGBA\", (width, height), buffer, \"raw\", \"BGRA\")\nim.save(\"frame50.png\")\n```\n\nLoading from JSON file, string of JSON, tgs; and rendering animation\n```python\nfrom rlottie_python import LottieAnimation\n\n# Loading from file\nanim = LottieAnimation.from_file(\"samples/sample.json\")\nanim.save_animation(\"animation1.apng\")\n\nanim = LottieAnimation.from_tgs(\"samples/sample.tgs\")\nanim.save_animation(\"animation2.gif\")\n\nwith open(\"samples/sample.json\", encoding=\"utf-8\") as f:\n    data = f.read()\n\nanim = LottieAnimation.from_data(data=data)\nanim.save_animation(\"animation3.webp\")\n```\n\nYou may also load animation using with statement\n```python\nfrom rlottie_python import LottieAnimation\n\nwith LottieAnimation.from_file(\"samples/sample.json\") as anim:\n    anim.save_animation(\"animation4.apng\")\n```\n\nNotice, if you are running on Linux and want to use rlottie_python in main process\nand child processes spawned by `multiprocessing.Process`, you may have to change\nstart method to `spawn`, or else deadlock may occur:\n```python\nif __name__ == \"__main__\":\n    multiprocessing.set_start_method(\"spawn\")\n```\n\n## Comparing to other library\nThe `lottie` (https://pypi.org/project/lottie/) python package is also capable of working with lottie files and telegram animated stickers (tgs). It is also able to support many input/output formats and vector graphics, without any dependency on extenral libraries such as librlottie. However some images it creates is broken ([Example1](https://github.com/laggykiller/sticker-convert/issues/5) [Example2](https://gitlab.com/mattbas/python-lottie/-/issues/95)). It seems librlottie is more stable in terms of rendering frames.\n\nThe `pyrlottie` (https://pypi.org/project/pyrlottie/) python package is also able to convert lottie and tgs files to webp/gif. However, it works by calling executables `gif2webp` and `lottie2gif` with subprocess, and it does not support macOS.\n\n## Building from source\n\nTo build wheel, run the following:\n```bash\ngit clone --recursive https://github.com/laggykiller/rlottie-python.git\ncd rlottie-python\n\n# To build wheel\npython3 -m build .\n\n# To install directly\npip3 install .\n```\n\n## Development\nTo run tests:\n```bash\npip install pytest\npytest\n```\n\nTo lint:\n```bash\npip install ruff mypy isort\nmypy\nisort .\nruff check\nruff format\n```\n\n## Credits\n- rlottie library: https://github.com/Samsung/rlottie\n- Packaging: https://github.com/tttapa/py-build-cmake","funding_links":["https://github.com/sponsors/laggykiller"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaggykiller%2Frlottie-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flaggykiller%2Frlottie-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaggykiller%2Frlottie-python/lists"}