Your rims look like they're about 30mm deep aluminum rims. I assume that you placed your ruler on the tire, such that the 0mm mark is probably a few mm to the right of the tread. Your tube sits on the rim's bead seat, so the presta valve probably starts around the 30mm mark on the ruler. That's around where the brake track ends, or maybe just after it.
You merely need enough space for your pump's chuck to seat onto the valve. On 30mm deep rims, I've typically used tubes with 48mm-long Presta valves. So, these are adequate. This page, which appears to be an online store, recommends 55mm Presta valves for 35mm and 40mm deep rims, and 60mm valves for 45 and 50mm deep rims. I'm not aware of tubes with 55mm valves right now.
I think that in the 2000s and earlier, rims used to be shallower, typically around 20-25mm. It's possible that tubes with 40mm valves, rather than 48mm, were more common then. 40mm long valves would be a very tight fit on 30mm deep rims. I think I did this a few times, and that it was tricky to seat my pump correctly. Some pumps have chucks that thread onto the valve, e.g. many Lezyne models, and it's possible these need less exposed valve to work.
Tubes with 60mm valves should be fine for up to about a 45mm deep rim. I know that there may be tubes that are even longer than that, but I believe they are rare. Another option is to use a valve extender: you'd unscrew the valve core, screw the extender on, and then screw the valve core into the extender. A couple of the answers to this question discuss valve core removal tools. Anyway, using valve extenders with deeper wheels enables you not to worry about what sort of spare tube you carry - although if you have a tubeless setup and deep wheels, you will want to ensure that your spare kit has a valve extender or a tube with a long enough valve.
Naturally, you can use a long valve stem on a shallower rim. Logically, there has to be a non-zero aerodynamic penalty, but this is probably small in most amateur cycling contexts.