The magnitude and spectral geometry