This is why you use PNG or GIF formats. Lossless compression on the PNG side and a LUT on the GIF side. Nothing to get compressed since it is literally just a grid of numbers and a table with the hex codes.
I really wish the social media companies and phone manufacturers would switch to PNG. So much better than JPG.