Downsizing works.
Palette remapping works.
Dithering works.
Use Floyd-Steinberg dithering.
Working good now. Time to make into an angular app.