A Weird Image Compression Program

Posted on Sun 23 April 2023 in Technology

If you're like me, you clogged up your entire hard drive with memes. I decided that I needed to clean up my computer a bit, so instead of doing the sensible thing and delete as many memes as I could bear, I decided to code an image compression program to free up space without degrading quality too much. I came up with this convoluted plan to convert images into 3D fourier transforms, remove low-frequency waves, and then convert back into an image. That was a bust, but I did notice something interesting. When I converted an image into a 3D array and converted it back into an image, the size went down without me actually doing anything to the image. I don't know why that happens, but I suspect it's at least partially because any metadata that the picture has is erased. The degree of compression depends on the image, but I've gotten over >80% reduction of size with particularly large and detailed images. For all the jpgs in my main directory, the total size went from 224 MB to 130 MB after compressing, a nice >40% reduction. The only problem is that some images end up completely destroyed. I don't know what causes it, but it seems to have to do with images being almost completely black to begin with. Still, I'm very pleased with the results.