We don't usually detect them directly. We observe a star dimming (planetary transit) or wobble and infer the planet's location, speed, and mass from that. We are only just developing techniques to observe very large planets close to their sun directly by efficiently cancelling out the sun's light.
Even a star wouldn't be anything more than a fat pixel, and the planet would be more like a thin pixel. Plus the star dimming, given the orbit would also be a long drawn phenomenon, like in case of earth(1 year).
I understand we ideally decide these things based on color of the light we see. And light waves stretch as the distance increases, and it can all be figured out by doppler effect.
But its still kind of mind blowing how much we can infer from just these things.
Its kind of mind blowing, we have techniques both theoretical and practical to only see pixels and yet come up with their exact dimensions.