In a system for variable-length coding, when image data of a plurality of
documents are compressed and stored in a compression memory, the image
data is divided into a plurality of areas. Then, attributes are
discriminated for each area, and the result of the attribute
discrimination is written to an attribute memory. Attribute counters
count the numbers of the discriminated attributes. A variable-length
compression section compresses the code data with a compression method in
response to the attribute data written to the attribute memory, and the
compressed data is written to a compression memory.