Every image format begins with a fixed signature — a JPEG with FF D8 FF, a PNG with 89 50 4E 47. WeChat XORs every byte of the file with the same key byte, so the first bytes of a .dat file reveal the key: XOR them with the expected signature and the key falls out. Applying the same XOR to the whole file restores the original image, bit for bit.
Three formats are recognised this way: JPEG, PNG and GIF, which covers nearly everything WeChat sends. A .dat whose first bytes do not match one of those signatures under any key is reported as skipped, never guessed at.
Converted files keep their name with the right extension, so 4f1c…e2.dat becomes 4f1c…e2.jpg. If two files would end up with the same name, the second gets -2. The ZIP stores images without recompressing them, so it is about the size of the folder and quick to build.
This happens in your browser. The images never leave your computer, which matters for private chat photos. For very large folders (tens of thousands of files), convert one month folder at a time so the browser does not run out of memory.