A boy who looks like his dad is sometimes said to be a spitting image of his father.
There is another expression, “spirit and image”, but it isn’t related.
At the apex of the glory that was the British Empire, just about every man was familiar with the spit and polish discipline of military life.
When a man polished his boots, he used saliva to bring them to where he could see his own reflection, and that is the origin of “spitting image.”