Wavelength- and alignment-dependent photoionization of N2 and O2