1. An image compositing apparatus for generating a composite image by composing a plurality of images captured while changing a focal position, the apparatus comprising: a memory that stores a computer program and data required to perform processing; and a computer that is connected to the memory and that performs processing according to the computer program, the computer comprising: a focal difference magnification calculation processor that calculates, for the plurality of images, a focal difference magnification, which is a magnification that changes in accordance with a difference between focal positions at which images are captured; a distortion correction magnification calculation processor that calculates, for the plurality of images, a distortion correction magnification, which is a magnification that changes when an image distortion in accordance with a focal position at which an image is captured is corrected; a magnification correction value calculation processor that calculates, for the plurality of images, a magnification correction value that corrects a magnification of the plurality of images so that image heights of the plurality of images that are changed by the focal difference magnification and the distortion correction magnification are consistent; and an area determination processor that determines an area used as an image for an image composition from among the plurality of images whose magnification was corrected by the magnification correction value, wherein the area determination processor determines an image that results in a minimum magnification correction value from among the plurality of images, and determines the area on the basis of the determined image.