An image processing method for laying out image data from a plurality of image data in slots of a template, the method comprising: performing (S406-S411) an object identification process on the plurality of image data; generating layout data on a basis of at least some of the plurality of image data subjected to the identification process and template data; controlling displaying of a layout image on a display on a basis of the layout data; and extracting replacement candidate images in response to a request for replacing an image selected by a user in the displayed layout image; characterized by acquiring setting information relating to a priority of a particular object; and in that the extracting includes a plurality of extraction steps for extracting a predetermined number of replacement candidate images on a basis of a set of extraction conditions, wherein the extracting uses different sets of extraction conditions for different priorities of the particular object, and wherein each extraction condition of a set of extraction conditions reflects the priority of the particular object corresponding to that set of extraction conditions, each of the plurality of extraction conditions corresponds to one of the extraction steps, is set (S1901, S1905, S1909, S1913) for that extraction step, and is an extraction condition of the set of extraction conditions which corresponds to the priority of the particular object related to by the setting information, and each extraction step extracts a replacement candidate image if that replacement candidate image meets the extraction condition corresponding to the extraction step, wherein the number of the replacement candidate images to be extracted in a second extraction step on a basis of a second extraction condition among the plurality of extraction conditions varies with the result of extraction of the replacement candidate images in a preceding first extraction step based on a first extraction condition among the plurality of extraction conditions so as to be equal to one if the number of the replacement candidate images extracted in the first extraction step is one, and so as to be equal to two if no replacement candidate image has been extracted in the first extraction step. performing (S406-S411) an object identification process on the plurality of image data; generating layout data on a basis of at least some of the plurality of image data subjected to the identification process and template data; controlling displaying of a layout image on a display on a basis of the layout data; and extracting replacement candidate images in response to a request for replacing an image selected by a user in the displayed layout image; characterized by acquiring setting information relating to a priority of a particular object; and in that the extracting includes a plurality of extraction steps for extracting a predetermined number of replacement candidate images on a basis of a set of extraction conditions, wherein the extracting uses different sets of extraction conditions for different priorities of the particular object, and wherein each extraction condition of a set of extraction conditions reflects the priority of the particular object corresponding to that set of extraction conditions, each of the plurality of extraction conditions corresponds to one of the extraction steps, is set (S1901, S1905, S1909, S1913) for that extraction step, and is an extraction condition of the set of extraction conditions which corresponds to the priority of the particular object related to by the setting information, and each extraction step extracts a replacement candidate image if that replacement candidate image meets the extraction condition corresponding to the extraction step, wherein the number of the replacement candidate images to be extracted in a second extraction step on a basis of a second extraction condition among the plurality of extraction conditions varies with the result of extraction of the replacement candidate images in a preceding first extraction step based on a first extraction condition among the plurality of extraction conditions so as to be equal to one if the number of the replacement candidate images extracted in the first extraction step is one, and so as to be equal to two if no replacement candidate image has been extracted in the first extraction step.