Images of flux vortices in superconductors acquired by transmission electron microscopy should allow a quantitative determination of their magnetic structure but so far, only visual comparisons have been made between experimental images and simulations. Here, we make a quantitative comparison between Fresnel images and simulations based on the modified London equation to investigate the magnetic structure of flux vortices in MgB2. This technique gives an absolute, low-field (~30 Oe) measurement of the penetration depth from images of single vortices. We found that these simulations gave a good fit to the experimental images and that if all the other parameters in the fit were known, the penetration depth for individual vortices could be measured with an accuracy of +/- 5 nm. Averaging over 17 vortices gave a penetration depth in the ab plane of 113 +/- 2 at 10.8 K assuming that the entire thickness of the sample was superconducting. The main uncertainty in this measurement was the proportion of the specimen which was superconducting. Allowing for a non-superconducting layer of up to 50 nm thickness on the specimen surfaces gave a penetration depth in the range 100-115 nm, close to values of 90 +/- 2 nm obtained by small-angle neutron scattering and 118-138 nm obtained by radio-frequency measurements. We also discuss the use of the transport of intensity equation which should, in principle, give a model-independent measure of the magnetic structure of flux vortices.