rlottie-rs icon indicating copy to clipboard operation
rlottie-rs copied to clipboard

Telegram skin recolor

Open yuraiz opened this issue 3 years ago • 9 comments

Telegram can recolor some animations to different skin colors image

but it's telegram's rlottie only feature https://github.com/TelegramMessenger/rlottie/commit/67f103bc8b625f2a4a9e94f1d8c7bd84c5a08d1d

If I understand correctly I need to implement capi in optional file and add feature to use it

yuraiz avatar Oct 27 '22 15:10 yuraiz

No, the C API isn't going to help you. The changes you linked to are only made to the C++ interface, the C interface is just a binding to that.

msrd0 avatar Oct 27 '22 15:10 msrd0

Looks like bindgen generate binding to C++: https://rust-lang.github.io/rust-bindgen/cpp.html

maybe I can make hpp wrapper and add load_from_data_tg function

yuraiz avatar Oct 27 '22 15:10 yuraiz

Yeah I see basically 3 options:

  • try to use bindgen with C++, or the cxx crate to bridge to C++ directly, which is likely going to be very painful
  • write some C wrapper ourselves
  • try to apply the color replacement as post-processing in Rust

Feel free to try these out and/or suggest other options that I might've missed. The last one might be favourable as it would work with either version of rlottie.

msrd0 avatar Oct 27 '22 15:10 msrd0

I made first working version image https://github.com/yuraiz/rlottie-rs/tree/fitz-recolor

yuraiz avatar Oct 27 '22 18:10 yuraiz

It looks like this should work with Samsung version of rlottie too (https://github.com/Samsung/rlottie/commit/3be663ef40122aca6c748e91f060e6b15637bdb5), but with a different api.

msrd0 avatar Oct 27 '22 22:10 msrd0

Telegram's fitzModifier gets replacement colors from json, and recolors skin only when Samsung's colorFilter will be applied to all colors

yuraiz avatar Oct 28 '22 06:10 yuraiz

Color filter can be useful for conversion, but I don't want to use it for skin recolor

yuraiz avatar Oct 28 '22 06:10 yuraiz

I can make feature 'v2' and add color filter later, but 'v2' and 'tg' features will be exclusive

yuraiz avatar Oct 28 '22 06:10 yuraiz

Telegram used to apply skin tone to faces Screenshot_20221028-070312_Telegram

yuraiz avatar Oct 28 '22 06:10 yuraiz