It is possible but libraries which do that are really slow.
You can save png with 16 bits instead of the standard 8 bits.
I guess the library is pypng or something like that. But as I’ve said, it’s very slow.