This is not guaranteed, but it can happen. Especially, if you repeat the encoding process for a long time β decode β encode β decode, then it will finally be installed on a fixed point and stop losing quality (if you adhere to the same quality and the same encoder).
JPEG encoding is performed in several stages:
- Convert RGB to YUV
- DCT (change in frequency domain)
- Quantization (discarding DCT bits)
- Lossless
And decoding is the same process back.
Steps 1 and 2 have rounding errors (especially in speed-optimized encodings using integer math), so for idempotent re-encoding you should be lucky that the rounding and decoding errors are small or cancel each other out.
Step 3, which is the main loss step, is actually idempotent. If your decoded pixels are converted to a similar DCT, it will again be quantized with the same data!
JPEG XR also uses YUV, so it may experience some rounding errors, but OTOH uses a different transformation instead of DCT that can be computed without rounding errors, so it should be easier to round JPEG-XR than other formats.
source share