1. An image processing apparatus configured to generate code information represented by a dot array and attach the code information on an image, the image processing apparatus comprising: a determination unit configured to determine one mask pattern from among a plurality of mutually-different mask patterns of locations to attach the code information, wherein the locations do not overlap with each other; and an attaching unit configured to attach the code information on the image at a location corresponding to the mask pattern determined by the determination unit.