Mobile app version of vmapp.org
Login or Join
Kaufman565

: Prevent white border effect when converting an image to grayscale with ImageMagick For printing images on a Epson TM-T88v receipt printer, I had to convert a PNG file to a 4-bit grayscale PNG

@Kaufman565

Posted in: #ColorConversion #FileConversion #Imagemagick

For printing images on a Epson TM-T88v receipt printer, I had to convert a PNG file to a 4-bit grayscale PNG by using ImageMagick.

Using the following command I'm getting pretty good results except of a white border around certain parts of the converted image:

convert test.png -depth 4 -colorspace gray -define png:color-type=0 -define png:bit-depth=4 test-4bit-gray.png


Original input image:



Converted image:



If I use Epson's native JS library to convert PNG images to 4-bit grayscale I get following result which looks way smoother:



Which ImageMagick options could help me to avoid the white border around the heart eyes of the Emoji or make it to look smoother at all?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Kaufman565

1 Comments

Sorted by latest first Latest Oldest Best

 

@Turnbaugh909

What you need is some dithering. There is some information on dithering techniques using ImageMagick here:


ImageMagick v6 Examples — Color Quantization and Dithering


Using -ordered-dither for the dither and removing the alpha gets you pretty close:



Converted with:

convert test.png -depth 4 -colorspace gray -alpha remove -ordered-dither o2x2,16 -define png:color-type=0 -define png:bit-depth=4 test-4bit-gray.png

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme