All the processing being made is pixel oriented and I'm using RgbQuant.js for color quantization. Many thanks to leeoniya for this amazing library.
To save the generated image just
Right Click > Save Image As...
Some links used to create this tool. As always Wikipedia is a great starting point to learn about something that I don't have any know-how. In this particular case the topics about color difference and color quantization were very helpful.