  We present a new method for high-resolution nanoscale magnetic resonance
imaging (nano-MRI) that combines the high spin sensitivity of nanowire-based
magnetic resonance detection with high spectral resolution nuclear magnetic
resonance (NMR) spectroscopy. By applying NMR pulses designed using optimal
control theory, we demonstrate a factor of $500$ reduction of the proton spin
resonance linewidth in a $(50\text{-nm})^{\text{3}}$ volume of polystyrene and
image proton spins in one dimension with a spatial resolution below
$2~\text{nm}$.
