Registry / serialization / lottie

lottie

JSON →
library0.7.2pypypi✓ verified 84d ago

A framework to work with Lottie files (Bodymovin JSON animations) and Telegram animated stickers (TGS format). Current version 0.7.2, supports Python >=3. Maintenance mode; no frequent releases.

pip install lottie
INSTALL
IMPORT
SIG · LOTTIE
L
lottie
serializationpythonv0.7.2
Install
2.8s avg
Import
361ms
Disk
19MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.7.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.380s · 21MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.8s · import 0.342s · 22MB
19MB installed
● package 19MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

lottie
import lottie
from lottie import *
Common mistake: wildcard import clutters namespace
NVector
from lottie.objects.base import NVector
from lottie import NVector
NVector is not in top-level module
Player
from lottie.player import Player
from lottie import Player
Player class moved to submodule in 0.7
export_tgs
from lottie.exporters.tgs import export_tgs
from lottie import export_tgs
export_tgs function not directly exposed
Color
from lottie.objects.base import Color
from lottie import Color
Color not in top-level module

Create a simple red circle animation and export as TGS.

import lottie from lottie import objects from lottie.exporters.tgs import export_tgs # Create a simple animation with a circle animation = objects.Animation() layer = objects.ShapeLayer() animation.add_layer(layer) # Add a circle shape shape = objects.ShapeElement() shape.shape = objects.Ellipse() shape.shape.position = objects.Point(0.5, 0.5) shape.shape.size = objects.Point(0.4, 0.4) layer.add_shape(shape) # Add a solid fill fill = objects.Fill() fill.color = objects.Color(1, 0, 0) # Red layer.add_shape(fill) # Export to TGS (Telegram Sticker) with open('sticker.tgs', 'wb') as f: export_tgs(animation, f) print('Done')
Debug
Known issues
deprecatedThe old `lottie.parsers` API is deprecated; use `lottie.importers` instead.
fix
Replace import from lottie.parsers with lottie.importers.
affects: >=0.7.0
gotchaAll coordinates and sizes are normalised 0-1, not pixel values. Using raw pixel values will result in invisible or off-screen elements.
fix
Divide pixel values by canvas dimensions to get normalised coordinates.
affects: All
gotcha`objects.Color` expects normalised RGB float (0-1), not 0-255 integers. Using 0-255 will produce washed-out colors.
fix
Divide RGB values by 255 when constructing Color.
affects: All
breakingIn version 0.7.0, the `NVector` class signature changed from (x,y) to (x,y,z) with z optional. Code using positional arguments may break.
fix
Update NVector calls to include z=0 explicitly if needed.
affects: 0.7.0+
Errors
Common errors & fixes
ImportError: cannot import name 'export_tgs' from 'lottie'
export_tgs is in a submodule, not top-level.
fix
Use: from lottie.exporters.tgs import export_tgs
AttributeError: module 'lottie' has no attribute 'NVector'
NVector is not directly exposed.
fix
Use: from lottie.objects.base import NVector
ValueError: Color values must be in range [0,1]
Using 0-255 integer values for Color.
fix
Divide each value by 255: Color(r/255, g/255, b/255).
TypeError: __init__() got an unexpected keyword argument 'position'
Older API used 'position' as argument; now set as attribute.
fix
Create instance then assign: shape.position = objects.Point(...)
Upgrade
Version history
0.7.2latest on PyPI · released May 1, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
8
Resources
lottie — pip install lottie · libregistry