My task is to reduce size of scanned text document into .png with acceptable quality loss. My procedure consist of those steps: Raw images are scanned in tif format and processed by ScanTailor (automatic tool for cutting double pages, fixing a tilt, cropping and converting to grayscale).

Batch proccesing by ImageMagick:

convert in.png  -resize 2000X2000 -sigmoidal-contrast 12,60% -colors 8 out.png

Final optimalization:

optipng in.png -o7 out.png

The problem is that option -colors 8 has worse size reducement then GIMP's Indexed color mode with "Optimal palette" with max 8 colors.

I also tried to

convert in.png -dither FloydSteinberg -remap colors.png  out.png

but a result was nearly the same as -colors option.

What does GIMP do in another way that it exports smaller png? Is there another good practice how to archive scanned text images and make them smaller in png with acceptable quality loss?

Here are images before optipng created with different methods.

Gimp method

ImageMagick -colors 8 method

ImageMagick -remap method

Color palette for remap

1 Answer 1


You reduce the number of colors but still use full-RGB format in the ImageMagick output. While, When the image is color-indexed, GIMP exports a color-indexed PNG. So you just have to tell ImageMagick to use the indexed-color PNG format:

convert input.png PNG8:output.png

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.