We study the optimal focusing of two-level atoms with a near resonant standing wave light, using both classical and quantum treatments of the problem. Operation of the focusing setup is considered as a nonlinear spatial squeezing of atoms in the thin-and thick-lens regimes. It is found that the near-resonant standing wave focuses the atoms with a reduced background in comparison with fardetuned light fields. For some parameters, the quantum atomic distribution shows even better localization than the classical one. Spontaneous emission effects are included via the technique of quantum Monte Carlo wave function simulations. We investigate the extent to which non-adiabatic and spontaneous emission effects limit the achievable minimal size of the deposited structures.