Could someone explain to me how compression algorithms work? Shouldn't they not work very consistently, by pigeonhole principle?
In this case they are making use of the fact that JPEGs store a certain mathematical formulation of a picture. It turns out JPEG doesn't store that mathematical formulation very well, so you can squash it loselessly into a better formulation, then later turn it back into the original JPEG.