By introduction of an optical gating beam on a semiconductor wafer, near-field terahertz (THz) imaging with a dynamic aperture has been realized. The spatial resolution is determined by the focus size of the optical gating bean and the near-field diffraction effect. THz imaging with subwavelength spatial resolution (better than 50mum) is demonstrated.