: 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
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?
More posts by @Kaufman565
1 Comments
Sorted by latest first Latest Oldest Best
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
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.