An image processing apparatus including: a processor; and a memory storing instructions that, when executed by the processor, cause the apparatus to perform: acquiring target image data and template image data; specifying a partial image in a target image based on a result of detecting a face area; and compositing the specified partial image in a specific area in a template image, wherein, when a single face area is detected, a first partial image including the single face area and having a size determined based on a size of the single face area is specified, and, when a plurality of face areas are detected, a second partial image including at least one of the face areas, having a shape homothetic to the specific area and having a maximum size within the target image is specified.