{"id":23994,"library":"lottie","title":"Lottie Python","description":"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.","status":"active","version":"0.7.2","language":"python","source_language":"en","source_url":"https://github.com/emilioastarita/lottie","tags":["lottie","bodymovin","telegram-stickers","animation","tgs"],"install":[{"cmd":"pip install lottie","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"Common mistake: wildcard import clutters namespace","wrong":"from lottie import *","symbol":"lottie","correct":"import lottie"},{"note":"NVector is not in top-level module","wrong":"from lottie import NVector","symbol":"NVector","correct":"from lottie.objects.base import NVector"},{"note":"Player class moved to submodule in 0.7","wrong":"from lottie import Player","symbol":"Player","correct":"from lottie.player import Player"},{"note":"export_tgs function not directly exposed","wrong":"from lottie import export_tgs","symbol":"export_tgs","correct":"from lottie.exporters.tgs import export_tgs"},{"note":"Color not in top-level module","wrong":"from lottie import Color","symbol":"Color","correct":"from lottie.objects.base import Color"}],"quickstart":{"code":"import lottie\nfrom lottie import objects\nfrom lottie.exporters.tgs import export_tgs\n\n# Create a simple animation with a circle\nanimation = objects.Animation()\nlayer = objects.ShapeLayer()\nanimation.add_layer(layer)\n\n# Add a circle shape\nshape = objects.ShapeElement()\nshape.shape = objects.Ellipse()\nshape.shape.position = objects.Point(0.5, 0.5)\nshape.shape.size = objects.Point(0.4, 0.4)\nlayer.add_shape(shape)\n\n# Add a solid fill\nfill = objects.Fill()\nfill.color = objects.Color(1, 0, 0)  # Red\nlayer.add_shape(fill)\n\n# Export to TGS (Telegram Sticker)\nwith open('sticker.tgs', 'wb') as f:\n    export_tgs(animation, f)\nprint('Done')","lang":"python","description":"Create a simple red circle animation and export as TGS."},"warnings":[{"fix":"Replace import from lottie.parsers with lottie.importers.","message":"The old `lottie.parsers` API is deprecated; use `lottie.importers` instead.","severity":"deprecated","affected_versions":">=0.7.0"},{"fix":"Divide pixel values by canvas dimensions to get normalised coordinates.","message":"All coordinates and sizes are normalised 0-1, not pixel values. Using raw pixel values will result in invisible or off-screen elements.","severity":"gotcha","affected_versions":"All"},{"fix":"Divide RGB values by 255 when constructing Color.","message":"`objects.Color` expects normalised RGB float (0-1), not 0-255 integers. Using 0-255 will produce washed-out colors.","severity":"gotcha","affected_versions":"All"},{"fix":"Update NVector calls to include z=0 explicitly if needed.","message":"In 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.","severity":"breaking","affected_versions":"0.7.0+"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use: from lottie.exporters.tgs import export_tgs","cause":"export_tgs is in a submodule, not top-level.","error":"ImportError: cannot import name 'export_tgs' from 'lottie'"},{"fix":"Use: from lottie.objects.base import NVector","cause":"NVector is not directly exposed.","error":"AttributeError: module 'lottie' has no attribute 'NVector'"},{"fix":"Divide each value by 255: Color(r/255, g/255, b/255).","cause":"Using 0-255 integer values for Color.","error":"ValueError: Color values must be in range [0,1]"},{"fix":"Create instance then assign: shape.position = objects.Point(...)","cause":"Older API used 'position' as argument; now set as attribute.","error":"TypeError: __init__() got an unexpected keyword argument 'position'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}