Post-acquisition correction of NMR spectra is an important part of NMR spectroscopy that enables refined NMR spectra to be obtained, clean from undesirable out-phasing, broadening and noising. We describe analytical and numerical mathematical methods for post-acquisition correction of NMR spectra distorted by static and dynamic magnetic field inhomogeneity caused by imperfections of main superconducting coils and the cold head operation, typical for cryogen-free magnets. For the dynamic inhomogeneity, we apply a variant of the general reference deconvolution method, complemented with our mathematical analysis of spectral parameters. For the static inhomogeneity, we apply the method of a delayed Fourier transform, also supported with our analytical calculations. We verify our approach by correction processing of high-field experimental liquid-state 1H NMR spectra of water and ethanol as well as solid-state 13C MAS NMR spectra of adamantane and obtain good results for both static and dynamic field distortions. This work complements our previous work on instrumental suppression of dynamic distortions caused by the cold head operation. The results presented contribute well to the general field of processing NMR spectra and serve towards a more extensive use of cryogen-free magnets in high-resolution NMR spectroscopy.