How JPEG works: Interactively explore JPEG's lossy compression methods
cgjennings.ca
cgjennings.ca
I finally understood DCT after watching https://www.youtube.com/watch?v=Q2aEzeMDHMA
And someone created a "JPEG to PNG" tool that "finds the smoothest possible picture that encodes to the given JPEG file": https://github.com/victorvde/jpeg2png . I tried it with some very terribly compressed images, and the outputs were a lot better.
Unfortunately, no common JPEG libraries expose these operations. Your only option is to use some crusty C-based code that hasn't been updated since the 2010-s.