This script realigns layers over a reference layer by scaling, rotating and translating them so that two designated points in each layer come to an exact overlap with two designated points in the reference image.
The script is invoked from Layers > Align layers in the usual image menus.
The script has no parameters, and works from the selected layers and the selected path.
These are the layers that are scaled/rotated, the reference layer should not be included. The layers are processed bottom-up.
The points are beforehand designated to the script as anchors in a path. There are to ways to use this:
Before calling, the path goes through the two points of the reference layer, then through the two points of the first adjusted layer, then through the two points on the second adjusted layer.


Layers are then selected in the layers list:

After execution, the adjusted layers have been moved/rotated/scaled so that the points overlap those on the reference layer:

The script uses the default interpolation method.