The invention discloses an automatic typesetting method for an electronic photo album, which is characterized by comprising the following steps of: S1, uploading photos to be typeset, sorting the photos according to shooting time, determining the number range of the photos typeset in each page according to the size of a selected template, and further determining the reference number of the photostypeset in each page; s2, determining the number of photos of each page through calculation according to the photo reference number; s3, counting the horizontal and vertical states of a plurality of photos, and formatting the horizontal and vertical states of the photos; s4, selecting an optimal template according to the formatting result and the size and the length-width ratio of the photo to thetemplate; s5, selecting the kth photo, determining the zoom scale of the photo according to the size of the photo and the size of the photo frame of the selected template, and placing the zoomed photo into the photo frame; and S6, repeating the above steps until all the photos are placed in the template. By utilizing the method, the number of typeset pictures is flexible, and the requirements ofdifferent users can be met; and the optimal typesetting effect can be achieved.