Text Without Alpha Channel

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
notkevinjohn
Posts: 4
Joined: 2018-09-04T15:25:08-07:00
Authentication code: 1152

Text Without Alpha Channel

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Text Without Alpha Channel

Post by snibgo »

How about "-threshold 50%"?
snibgo's IM pages: im.snibgo.com
notkevinjohn
Posts: 4
Joined: 2018-09-04T15:25:08-07:00
Authentication code: 1152

Re: Text Without Alpha Channel

Post by notkevinjohn »

Nevermind, I figured it out. I could just turn off anti-aliasing with the +antialias command
notkevinjohn
Posts: 4
Joined: 2018-09-04T15:25:08-07:00
Authentication code: 1152

Re: Text Without Alpha Channel

Post 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).
Post Reply