Using the technique of parallax, we can take 2 photos of a star 6 months apart, when the Earth is on different sides of the solar system. Be measuring the shift of the star relative to more distant stars, we can tell how far away the star is.