Fetching Palette data from texture upon import

I need to fetch palette from indexed color texture upon import - preferably from within AssetPreprocessor::OnPreprocessTexture, but it could also be done elsewhere.

Basically, I’m looking for a way to access some raw image manipulation routine from within unity. System.Drawing.Graphics are not accessible by default, and unity does not seem to expose libpng bindings. Ideas?

P.S. Trying to guess palette data from RGB colors is not an option.

As detailed here:
https://forum.unity3d.com/threads/replace-image-palette-upon-import.472534/

I’ve “solved” the issue by writing a native plugin that loads png texture and palette using assetpath.

if anyone knows a better way to do it, I’m all ears.