Your task is to, given an image, compress it to 100000 bytes or less, while following all of the below rules:
Your code must not be optimized to work best only on the test set of images, but rather produce a good output in general.
Colours that do not exist in the original input image must also not exist in the output image. You do not necessarily have to use all of the colours in the input image, so you may use a subset of them if you want to, but, there must not be any extra colours in the output image that were not present in the input image.
The input will be at minimum of image types/file extensions JPG, PNG, GIF (including animated GIFs), and BMP. Your code may support any additional formats for input and output beyond the minimum described above, if you want to.
The output image must remain in the same file format/extension as the original image, unless your code doesn't support a format and you'd need to convert it. Conversion processing must be done losslessly and outputted to a lossless file format. Therefore, there must not be anything added or removed at all from the image during the format conversion process.
The maximum filesize of the output image after compression is exactly 100000 bytes.
You must not losslessly compress images. Theoretically speaking, "any lossless compression algorithm that makes some files shorter must necessarily make some files longer."
The output image must have the exact same dimensions/size as the input image.
Theoretically speaking, every possible input your algorithm/code gets must produce an output of 1000000 bytes or less.
Your code must produce good output on most images in general, but, for this challenge, you must test your code on this test set of images and upload your output.
You must also show the code that you used, and not just the output images.
Your score is determined by the sum the squared difference between the input and output images.
As an example:
If the first pixel in the uncompressed image is RGB (2,3,4) and the first pixel in the compressed image is RGB (5,6,7), then the squared distance for that pixel is (2-5)^2+(3-6)^2+(4-7)^2, and then you sum that up for all the pixels.
Thank you, and good luck!