Scanning probe microscopy methods1,2 can image samples with extremely high resolutions, opening up a wide range of applications in physics3, chemistry4 and biology5. However, these passive techniques, which trace the sample surface softly, give indirect topographic information. Here, we show an active imaging technique that has the potential to achieve optically a molecular resolution by directly interacting and perturbing the sample molecules. This technique makes use of an external pressure, applied selectively on a nanometric volume of the sample through the apex of a sharp nanotip, to obtain a local distortion of only those molecules that are pressurized. The vibrational frequencies of these molecules are distinctly different from those of unpressurized molecules. By sensing this difference, our active microscopic technique can achieve extremely high resolution. Using an isolated single-walled carbon nanotube and a two-dimensional adenine nanocrystal, we demonstrate a spatial resolution of 4 nm. Applying external pressure to a sample molecule via the apex of a sharp nanotip allows tip-enhanced Raman imaging of molecules with a spatial resolution of 4 nm.