The strong-interaction effects both in pionic hydrogen and deuterium have been re-determined with improved precision. The hadronic shift and width in pionic hydrogen together with the hadronic shift in pionic deuterium constitute a one-fold constraint for the two independent pion-nucleon scattering lengths. Furthermore, the hadronic width in pionic deuterium measures the transition strength of s-wave pions on an isoscalar nucleon-nucleon pair which is an independent quantity not related to the pion-nucleon scattering lengths. The experiment was performed at the high-intensity low-energy pion beam of the Paul Scherrer Institute by using the cyclotron trap and a high resolution Bragg spectrometer with spherically bent crystals. The pion-nucleon scattering lengths and other physical quantities extracted from the atom data are in good agreement with the results obtained from pion-nucleon and nucleon-nucleon scattering experiments and confirm that a consistent picture is achieved for the low-energy pion-nucleon sector with respect to the expectations of chiral perturbation theory.