eilvelia / tdl

Node.js bindings to TDLib 🥒
MIT License
411 stars 53 forks source link

Need guidance how to interprete minithumbnail data #168

Closed hollyhook closed 3 months ago

hollyhook commented 3 months ago

Receiving a message with content._ :"videoMessage", there is an attribute minithumbnail, which looks like this for example

 minithumbnail: {
    _: 'minithumbnail',
    width: 40,
    height: 22,
    data: '/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDACgcHiMeGSgjISMtKygwPGRBPDc3PHtYXUlkkYCZlo+AjIqgtObDoKrarYqMyP/L2u71////m8H////6/+b9//j/2wBDASstLTw1PHZBQXb4pYyl+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj/wAARCAAWACgDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwC3JLChwzjNIpjc4R1J9jWO2G6SAfWnRmONgRKS3sMU1Ni5TY8qq9yGjAI6GoknkAY7mO0evemrJJMmN+5fehzug5RhkbBHrRU5t16rIM+4orO5Vil9mAGSx/AVGyqk+3kiiiqEX0AYAnhfQVEsoSR4guAORiiikMkE6ktlSAPSiiinYD//2Q=='
  }

In tdlib documentation it is said that it is jpeg format. Could you help how this string can be decoded to binary jpeg? Thanks!

eilvelia commented 3 months ago

You need to base64-decode it. Buffer.from(minithumbnail.data, 'base64') can be used.