I am working on my own "everyday face" project - taking pictures of myself to combine them in a sequence afterwards.

I'm wondering what is the easiest and fastest way to align all pictures so my eyes would be in the exactly the same position for all of the pictures.

Parameters like the distance from my face to the camera and position of head in all pictures are very similar, but change a little bit from picture to picture.

What is the fastest way to align the pictures based on the position of the eyes?

  • \$\begingroup\$ Or see other answers in the auto-alignment tag. \$\endgroup\$
    – mattdm
    Commented Apr 17, 2014 at 16:44
  • \$\begingroup\$ For animation, see my answer to the duplicate question \$\endgroup\$ Commented Jan 10, 2017 at 21:08
  • 1
    \$\begingroup\$ I don't think it is a duplicate since aligning faces is somehow a special task. There is special software available to detect face positions such as thregr.org/~wavexx/software/facedetect. Unfortunately I cannot post this as an answer. I suggest to open this question again but change the title to better reflect the questions, e.g. “How to auto-align a sequence of headshots”. \$\endgroup\$
    – Chris
    Commented Jul 13, 2017 at 11:12
  • \$\begingroup\$ @Chris You make a good case. Face detection & alignment is a subset special case of the general image stacking (which usually assumes identical(-ish) images all stacked and aligned. I've nominated for reopening. \$\endgroup\$
    – scottbb
    Commented Jul 13, 2017 at 14:46
  • \$\begingroup\$ Learn OpenCV: Average Face: OpenCV (C++ / Python) Tutorial \$\endgroup\$
    – xiota
    Commented Aug 10, 2019 at 7:12

4 Answers 4


I don't know if it's the easiest but this works pretty well for my needs:

$ align_image_stack -a aligned -C *.jpg

'align_image_stack' utility is part of hugin, and under Debian/Ubuntu (and other derivatives probably) you acquire it by installing 'hugin-tools' package. In the command above:

  • '-a aligned' sets prefix of the name of output images to 'aligned'
  • '-C' crops output images to the area covered by all images
  • '*.jpg' tells the program to work on all jpg images in current directory.
  • \$\begingroup\$ Thank you for respond. Where this should be written? I'm using Mac, I've downloaded Hugin, but it has GUI. How I can install hugin tools? thanks \$\endgroup\$
    – user40
    Commented Apr 17, 2014 at 23:44
  • \$\begingroup\$ Ok, I've tried this on ubuntu, doesn't really works well. It does align a little bit, but eyes are still "moving" from picture to picture, even though only a little of aligning is required - pictures are taken with a good accuracy. \$\endgroup\$
    – user40
    Commented Apr 17, 2014 at 23:57
  • \$\begingroup\$ I have 400 images and this has been running for 2 days solid and still has not written any output images. Does it have an O(N^2) running time or something? \$\endgroup\$
    – RandomEngy
    Commented Jun 7, 2016 at 5:33
  • \$\begingroup\$ > Align_image_stack works only with images of the same size. \$\endgroup\$
    – handle
    Commented Jul 7, 2017 at 11:43
  • \$\begingroup\$ @user40 you can access the command via /Applications/Hugin/tools_mac/align_image_stack \$\endgroup\$
    – Aaron Fi
    Commented Apr 3, 2020 at 8:35

The easiest way is probably to just use Hugin.

The command line tool that's actually doing all the work below the Hugin GUI is align_image_stack, and if you install Hugin, you should just be able to type it on the command line directly, but the Hugin GUI is probably easier to use.

From the hugin web pages (should work with the current 2013 version of Hugin):

Aligning with hugin

  1. Start up a new hugin project for each series and load the images. Set the Field of View, lens parameters and projection type, i.e., if your lens is a fisheye, set this for both the input and output projection.

  2. Create control points via the Photos tab. Align_image_stack is specialized for this task. But also Panomatic or Cpfind work for this use case.

  3. Select "Positions (y,p,r)" and "Optimise now!" in the Photos tab.

  4. If necessary, fine tune the control points in the Control Points tab and optimise again.

  5. In the fast panorama preview, the images will be on top of each other. Select "Move/Drag" and "Fit", then select "Crop" and "HDR Autocrop".

  6. In the Stitcher tab, select "Calculate Optimal Size", then deselect the default panorama outputs and select "No exposure correction, low dynamic range" in the "Remapped images" section. Select "Stitch!".

You will probably want to manually set the control points for your eyes, and possibly erase all the other points, since you don't care about any other details matching.

  • 1
    \$\begingroup\$ I had trouble disabling exposure correction. Interface->Expert, Photos tab, Set Photometric (bottom) to Custom (unlocks exposure tab), Exposure tab, Reset to Zero. Then stitch. \$\endgroup\$
    – jozxyqk
    Commented Jan 22, 2015 at 7:28

There is special software for face detection available which may help to align head shots. While I don't know of an out-of-the-box solution, you could start e.g. with the face detection software from https://www.thregr.org/~wavexx/software/facedetect/. It can output position and size of detected faces and you can use it in a script. It could work as long as you don't need rotation. Probably, the software can be adapted to even tell the eyes' positions, which could be used for determination of required rotation, but there may be other options as well. Maybe connect with the author of the software if you need such additional figures.


How many pictures? If it is only a few, the easiest is to use Photoshop, two rulers, and onion skin (make two layer, one photo is not transparent, the one above is semi-transparent), and move the pictures with mouse or fine-tune with arrow keys.

If you get into it, a few hundred pictures goes pretty fast.

Do not use onion skin by itself, use rulers as well, otherwise you will tend to drift a bit away with the center of the eyes.

Also, if the distance between the eyes is not completely constant, you will have to use Free Transform anyway....

  • 1
    \$\begingroup\$ That's what I've tried before posting here. Didn't find it fast) but thanks. \$\endgroup\$
    – user40
    Commented Apr 18, 2014 at 0:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.