1. An image processing apparatus comprising: a processor configured to operate as: a reduction unit configured to execute color-number reduction processing for each block configured by a plurality of pixels included in a processing target image expressed by processing target image data, the color-number reduction processing comprising reducing the number of colors expressed by the plurality of pixels in the block to generate image data having the reduced number of colors from the processing target image data, a gradation-number of each color value included in the image data having the reduced number of colors being the same as a gradation-number of each color value included in the processing target image data; and a compression unit configured to execute compression processing using the image data having the reduced number of colors to generate compressed image data, wherein the reduction unit is configured to execute first color-number reduction processing by using a first type of the block constituted by N1 pixels, N1 being an integer of 2 or larger, wherein when a data size of the compressed image data after the first color-number reduction processing is larger than a threshold value, the reduction unit is configured to execute second color-number reduction processing by using a second type of the block constituted by N2 pixels, N2 being an integer larger than N1, and wherein the processing target image data used in the second color-number reduction processing is the processing target image data before the first color-number reduction processing.