An image processing apparatus 3 is provided with a hardware processor that acquires first image data and second image data which is different from the first image data from among a plurality of pieces of image data, detects a width in a direction orthogonal to a direction in which a first image based on the acquired first image data and a second image based on the second image data are arranged side by side, corrects, when the detected width of the first image is different from the width of the second image, at least one piece of image data of the first image data and the second image data so that the widths of both pieces of image data come closer to each other, and combines a plurality of pieces of image data including the corrected image data to thereby generate one piece of lengthy image data.