Results 1 to 9 of 9

Thread: New Telegram animated image format

  1. #1
    Member SolidComp's Avatar
    Join Date
    Jun 2015
    Location
    USA
    Posts
    222
    Thanks
    89
    Thanked 46 Times in 30 Posts

    New Telegram animated image format

    Hi all — Telegram just pushed an update that includes animated stickers using a format they developed called .TGS. It looks like it's extremely compact, and supports 60 frames per second. See the screenshot:

    Click image for larger version. 

Name:	Screenshot_20190706-180536_Telegram.jpg 
Views:	84 
Size:	859.4 KB 
ID:	6706

    They said that it's "Lottie-based". I didn't know what that was, but I think it's this project from airbnb.

  2. The Following 2 Users Say Thank You to SolidComp For This Useful Post:

    GOZARCK (9th July 2019),snowcat (8th July 2019)

  3. #2
    Administrator Shelwien's Avatar
    Join Date
    May 2008
    Location
    Kharkov, Ukraine
    Posts
    3,134
    Thanks
    179
    Thanked 921 Times in 469 Posts

  4. #3
    Member SolidComp's Avatar
    Join Date
    Jun 2015
    Location
    USA
    Posts
    222
    Thanks
    89
    Thanked 46 Times in 30 Posts
    Quote Originally Posted by Shelwien View Post
    Do you see it in the code? I don't see any obvious deflate files.

  5. #4
    Administrator Shelwien's Avatar
    Join Date
    May 2008
    Location
    Kharkov, Ukraine
    Posts
    3,134
    Thanks
    179
    Thanked 921 Times in 469 Posts

  6. #5
    Member SolidComp's Avatar
    Join Date
    Jun 2015
    Location
    USA
    Posts
    222
    Thanks
    89
    Thanked 46 Times in 30 Posts
    Interesting. It's a vector format and I guess it's not surprising that DEFLATE could help with that. It's much better than GIF but it's easy to beat GIF since it's 32 years old. It would be interesting to see how much better TGS could be with zstd, brotli, or one of the Oodle compressors.

  7. #6
    Programmer schnaader's Avatar
    Join Date
    May 2008
    Location
    Hessen, Germany
    Posts
    539
    Thanks
    192
    Thanked 174 Times in 81 Posts
    Some more infos: Lottie itself seems to be a JSON-based format, but at the moment I'm not sure if the Telegram format is just a GZip wrapper around this or more is involved. At least there are some requirements for Lottie files to be valid .tgs - though the list and this issue seems to indicate these are just "cosmetic" requirements (size, framerate, length of animation) or limited functionality regarding the whole Adobe After Effects/Lottie superset. They suggest a Adobe After effects plugin there for creation which makes it harder to create some test animations, also I don't see where the Telegram Desktop application stores (animated) stickers, they seem to have some containered structure instead.

    The site LottieFiles.com has some user created Lottie animation examples, most of them are in JSON format with minimal formatting and short strings, like this (fragment of the beginning of a file):

    Code:
    {"v":"5.5.0","fr":24,"ip":0,"op":57,"w":472,"h":472,"nm":"Heart 03","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":3,"ty":4,"nm":"Drop 12","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":181,"ix":10},"p":{"a":0,"k":[236,235.5,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[44,44,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":1,"k":[{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":45,"s":[{"i":[[0.013,0.002],[0.02,-0.074],[-0.008,-0.026],[-0.022,0.005],[0.002,0.1],[0.01,0.019]],"o":[[-0.051,0.043],[-0.025,0.092],[0.006,0.046],[0.022,-0.005],[-0.003,-0.013],[-0.007,-0.014]],"v":[[-122.856,-13.795],[-122.961,-13.602],[-122.982,-13.394],[-122.896,-13.33],[-122.807,-13.709],[-122.825,-13.767]],"c":true}]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":46,"s":[{"i":[[-0.765,-0.062],[-0.931,3.357],[0.21,2.636],[1.578,-0.962],[-3.421,-12.026],[-0.685,-0.347]],"o":[[1.49,-3.209],[1.152,-4.156],[-0.38,-4.766],[-1.578,0.962],[0.214,0.752],[0.492,0.249]],"v":[[-122.607,31.222],[-118.901,21.118],[-117.349,10.447],[-122.877,11.932],[-125.818,29.122],[-124.486,30.759]],"c":true}]},
    Using 7-Zip ultra settings and paq8p on this .json file, we get the following compression results:

    Code:
    215.030 7512-blue-heart.json
     21.522 7512-blue-heart.json.zip
     21.387 7512-blue-heart.json.gz
     18.850 7512-blue-heart.json.bz2
     12.501 7512-blue-heart.json.7z
      9.503 7512-blue-heart.json.paq8p.3
    I guess some custom binary format would be even better than GZip, but they just chose something that is already available and fulfills the decompression speed/memory requirement. And perhaps they just didn't consider LZMA(2) or it just works well on this specific file.
    http://schnaader.info
    Damn kids. They're all alike.

  8. #7
    Member
    Join Date
    Jan 2017
    Location
    Germany
    Posts
    48
    Thanks
    25
    Thanked 10 Times in 7 Posts
    PAQ is not the most sensible choice for that use case. Brotli is probably an even better choice compared to 7-zip.

    11.522 7512-blue-heart.json.br (Brotli default settings)

  9. The Following User Says Thank You to WinnieW For This Useful Post:

    schnaader (9th July 2019)

  10. #8
    Programmer schnaader's Avatar
    Join Date
    May 2008
    Location
    Hessen, Germany
    Posts
    539
    Thanks
    192
    Thanked 174 Times in 81 Posts
    Quote Originally Posted by WinnieW View Post
    PAQ is not the most sensible choice for that use case. Brotli is probably an even better choice compared to 7-zip.
    Yes, paq8p was only used to provide kind of a lower limit, it's much too slow of course. Nice to see that brotli performs well here.

    The .tgs format is indeed gZipped Lottie, here's a GitLab repository that has some reverse engineering results and Python scripts. The lottie2tgs script is basically a gZip invocation. The repository also contains a Synfig studio (open source 2D animation software) plugin so Adobe After Effects is not a requirement anymore (though I haven't tried if it works like it should).
    http://schnaader.info
    Damn kids. They're all alike.

  11. The Following 2 Users Say Thank You to schnaader For This Useful Post:

    Shelwien (10th July 2019),WinnieW (9th July 2019)

  12. #9
    Member
    Join Date
    Jan 2017
    Location
    Germany
    Posts
    48
    Thanks
    25
    Thanked 10 Times in 7 Posts
    I asked myself why Telegram picked the old deflate method instead of a modern algorithm, like Brotli.

Similar Threads

  1. PIK image format
    By Jyrki Alakuijala in forum Data Compression
    Replies: 72
    Last Post: 29th May 2019, 23:39
  2. FLIF - Free Lossless Image Format
    By willvarfar in forum Data Compression
    Replies: 173
    Last Post: 28th February 2019, 19:04
  3. Free Universal Image Format (FUIF)
    By SolidComp in forum Data Compression
    Replies: 2
    Last Post: 12th January 2019, 21:18
  4. Replies: 3
    Last Post: 23rd August 2018, 20:27
  5. Apple's new HEIF image format
    By SolidComp in forum Data Compression
    Replies: 4
    Last Post: 22nd February 2018, 13:32

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •