GIMP Script-fu

Fit Face to Path
"<Image>/Layer/Fit Face to Path"
PDB Name:
sg-fit-face.scm (after the page appears, click on the "Download" command)


This script adds a command to the Layer Menu which will scale and rotate the current layer such that it is oriented and sized to fit over the region determined by the entered path points.

The script is generally intended for superimposing one person's face on another's body; though it is not limited to "faces". It may also be useful for creating collages or for cartography overlays (as discussed in this thread on the Meet The GIMP forums).

To use the script, you would typically have both graphics (the substitute face and the original model) as separate layers in the same image. You would then use the Path Tool to mark the start and end points of a path that spans between two notable features on the "face" layer (the top of the face and the bottom of the face being the most obvious choice, but the script also works with paths for ear-to-ear or eye-to-eye, etc). You then would hide the face layer (if necessary) then hold down the SHIFT key and click on the position of the first notable feature on the "model" layer, release the SHIFT and click on the second feature as it appears on the "model" layer. With the "face" layer active, you would then run the script ("Layer->Fit Face to Path").

For those unfamiliar with the Path Tool, what you are doing is creating a single path comprising two separate "strokes" (disconnected segments). The first stroke is a two-point line from one feature to the next as they are located on the "face" (or source) layer, and the second stroke is a two-point line that specifies the correlating points on the "model" layer. When drawing a path, newly created anchors are added to the same stroke unless you hold down the SHIFT key as you create a new anchor, in which case a new stroke is started. The new stroke is NOT a new path, it is a separate segment which will be part of the same path.

Here is an animated GIF which attempts to demonstrate the process: