Page 1 of 1

Possible bug with "-remap"

Posted: 2018-07-31T02:40:40-07:00
by Lecram

Code: Select all

ImageMagick 6.9.7-4 Q16 x86_64 20170114
Ubuntu 17.10
4.13.0-46-generic x86_64
When converting a 16 bpp grayscale image into a 8 bpp grayscale image with -remap using a palette of 256 distinct shades of gray, the resulting image is only made up of no more than 64 distinct shades of gray.

The expected behavior would be the creation of an image using the full range of shades supplied by the palette.

Code to reproduce:

Code: Select all

#!/bin/bash

# Create high color depth test image
convert -size 256x512 gradient:"black-white" "bw-gradient-int_16.png"

# Create a palette for conversion/reduction to 256 shades of gray
convert -size 256x1 gradient:"black-white" "palette.png"

# Reduce the depth from 16 to 8 bits using the palette
convert "bw-gradient-int_16.png" -remap "palette.png" -dither FloydSteinberg -depth 8 "bw-gradient-int_8.png"

# Determine the amount of distinct colors in the resulting image
convert "bw-gradient-int_8.png" -format %[k] info:
Please see this thread for further reference.