An image processing apparatus performs variable-length compression on the
image data of each block included in one page, and adds a bit to the
resultant code data of each block to make it have a constant data length.
The apparatus stores the data length of the added bit. On the other hand,
the apparatus stores a variable-length code from which the added bit is
erased in a storage. If it is determined that respective bits are added
to all blocks to make them have the constant data length, the apparatus
adds respective bits of different data lengths to variable-length codes
read from the storage, thereby converting the data lengths of the blocks
into a shorter constant data length than the constant data length.