It's not done on pictures.
The ball has a device inside it, so that when it passes behind the the two posts it sends a signal to the referees watch that it was a goal. So there's literally no margin for error.
Wrong.
There is no device in the ball. Its the same system used by tennis, cricket and so forth. It tracks the ball with multiple cameras. It has something like a 99.8% accuracy but its not 100% accurate as it actually uses multiple cameras to track the ball and predict where it will go by triangulating all the camera angles. It might be 100% for football due to the size of the ball but I know it has deficiency of 5mm of error which isn't very much on a bigger ball let alone a tennis/cricket ball.
Either way that goal was not a goal. Id say a good inch was still on the line if not more.