IM won't draw text on CMYK images, so I am first drawing the text onto a temporary RGB image and then converting the colorspace. I am using the correct ICC profiles and the color conversion seems accurate, and the output looks good. The problem is that when the colorspace is converted the source image seems to lose its transparency and gets a white background. Then I have to make the white area transparent before composing it onto the background. The problem is that I can't use white text because then it gets blanked as well. I also can't seem to control which color the transparency is converted to (so it's different than the white text). I can't find a way to keep the transparency on a colorspace conversion, which would also solve my problem. Am I hitting a known limitation or is there something else I can do?
Code: Select all
//Image is destination CMYK background image MagickImage txtImage = new MagickImage(bgColor, curGeo.Width, curGeo.Height); //font/color setup omitted txtImage.Read("caption:" + text); txtImage.AddProfile(Image.GetProfile(prof)); txtImage.ColorSpace = Image.ColorSpace; //reinstate transparency txtImage.Transparent(new ColorCMYK(0, 0, 0, 0, 1)); Image.Composite(txtImage, curGeo, CompositeOperator.SrcOver);
Code: Select all
var black = new MagickColor(Color.Black); var mi = new MagickImage(black, 500, 500); mi.Font = "Arial"; mi.TextGravity = Gravity.Center; mi.AntiAlias = true; mi.FontPointsize = 64; mi.FillColor = new MagickColor(Color.White); mi.Annotate("My Mask", Gravity.Center); mi.Write("text_mask.png"); //has anti-aliased white on black var mi = new MagickImage(MagickColor.Transparent, 500, 500); mi.Mask = new MagickImage("text_mask.png"); mi.Tile(new MagickImage("g-pink.png"), CompositeOperator.Blend); mi.Write("text_maskfill.png");
tl;dr - I'm trying to draw good-looking text of all colors on CMYK backgrounds. Please let me know if I'm barking up the wrong tree with my examples or I have in fact just met some limitations of IM.
EDIT: mark solved