Page 1 of 1

Text Without Alpha Channel

Posted: 2018-10-01T08:44:44-07:00
by notkevinjohn
I'm working on generating images and labels that are going to be printed on a device that uses a ribbon of toner, and does not apply any kind of grey scale, it's truely black and white. I am dynamically generating some text for this image, but I have been discovering small artifacts that appear on the printed label, but not on the image when I view it on the screen.

A deeper investigation made it clear that I was passing an image with some greyscaling to the printer, and it was applying some threshold to convert that to a 2 color image, which introduced these artifacts. Further investigation revealed that its the way image magick handles fonts that introduces these greyscale artifacts. To create smooth edges of the text (which I assume starts of as a vector and is rasterized into pixels) the program introduces edges that smoothly interpolate from black to white, which makes it look nice on images that can provide more than two colors. This would probably also look fine on higher resolution 2 color images where the effect would be negligible, but in my application the images are only 400x400 pixels.

My question is this: is there a method I can use to prevent image magick from applying these grey-scaled edges to the font, and force it to rasterize the text (as smoothly as it can) using ONLY black and white? Here is an example of the code I execute now to create one of the labels:

magick convert -background white \
-fill black -pointsize 67 -font Arial-Bold label:"$Serial" \
serial.mpc

Re: Text Without Alpha Channel

Posted: 2018-10-01T08:54:22-07:00
by snibgo
How about "-threshold 50%"?

Re: Text Without Alpha Channel

Posted: 2018-10-01T09:09:36-07:00
by notkevinjohn
Nevermind, I figured it out. I could just turn off anti-aliasing with the +antialias command

Re: Text Without Alpha Channel

Posted: 2018-10-01T09:10:56-07:00
by notkevinjohn
snibgo wrote: 2018-10-01T08:54:22-07:00 How about "-threshold 50%"?
Yeah, that was my first thought too, and it was how I figured out what was wrong. This exposed the artifacts in the image (before it went to the printer) but did not eliminate them (even after spending some time tinkering with the percentage).