  The optical path lengths travelled by rays across a wavefront essentially
determine the resulting phase front irrespective of the shape of a medium
according to the principle of equal optical path. Thereupon we propose a method
for the transformation between two arbitrary wavefronts by a slab, i.e. the
profile of the spatial separation between the two wavefronts is taken to be
transformed to a plane surface. Interestingly, for the mutual conversion
between planar and curved wavefronts, the method reduce to an inverse
transformation method in which it is the reversed shape of the desired
wavefront that is converted to a planar one. As an application, three kinds of
phase transformation are realized and it is found that the transformation on
phase is able to realize some important properties such as phase reversal or
compensation, focusing, and expanding or compressing beams, which are further
confirmed by numerical simulations. The slab can be applied to realizing
compact electromagnetic devices for which the values of the refractive index or
the permittivity and permeability can be high or low, positive or negative, or
near zero, depending on the choice of coordinate transformations.
