Poor text rendering with Annotate in newer Magic++

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Post Reply
imPhil
Posts: 5
Joined: 2019-02-05T02:54:26-07:00
Authentication code: 1152

Poor text rendering with Annotate in newer Magic++

Post by imPhil » 2019-02-05T03:36:05-07:00

We recently upgraded from MSVC-2010 to MSVC-2017 and moved from ImageMagick-6.9.1-Q16 to ImageMagick-7.0.7-15.
The text rendered with Image::annotate is noticeably more jagged with the new version. Is there anything we can do to improve it?

We use this Magic++ code to read an image file (in this case plain black) and add multiple lines of text.

Code: Select all

Magick::Image graphicImage("graphic.jpg");
resizeImage(graphicImage, 1920, 1080); // it's this size to start with
graphicImage.fillColor(Magick::Color(0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF));
graphicImage.textEncoding("UTF-8");
graphicImage.textAntiAlias(true); // without this doesn't make any difference
graphicImage.font("Ariel"); // True type font
int nLines = 16;
graphicImage.fontPointsize(((1080 / 96.0) / nLines) * 72.0);
std::string sText;
const char *pPfx = "";
for (std::vector<std::wstring>::const_iterator it = textOverlays.m_vecText.begin(); it != textOverlays.m_vecText.end(); ++it)
{
	sText += pPfx;
	pPfx = "\n";
	sText += toUtf8(*it);
}

MagickCore::GravityType grav = MagickCore::CenterGravity;
	
Magick::Geometry boxSize(
		(unsigned int)(1920 * 0.9),
		(unsigned int)(1080 * 0.9),
		(unsigned int)(1920 * 0.05),
		(unsigned int)(1080 * 0.05));
graphicImage.annotate(sText, boxSize, grav);

snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Poor text rendering with Annotate in newer Magic++

Post by snibgo » 2019-02-05T04:09:13-07:00

Please link to sample outputs you get from v6 and v7.
snibgo's IM pages: im.snibgo.com

imPhil
Posts: 5
Joined: 2019-02-05T02:54:26-07:00
Authentication code: 1152

Re: Poor text rendering with Annotate in newer Magic++

Post by imPhil » 2019-02-05T08:19:24-07:00

Image

The left side is taken from the new version the right side is the old. The font size and positioning has changed slightly as well. My two images have not been scaled, but they are cropped slightly differently -- the positioning is not as far out as they seem here.

snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Poor text rendering with Annotate in newer Magic++

Post by snibgo » 2019-02-05T10:06:59-07:00

Both samples are anti-aliased. Are you using the same font? You use "Ariel", not the more usual "Arial". (If you don't have an "Ariel" font, IM will use a default, which may be "Arial".) Do you have the same version of freetype?

If you have command-line version of IM, I suggest you try that in both versions, eg:

Code: Select all

f:\web\im>%IM%convert -size 1920x1080 xc:Black -fill White -font Ariel -pointsiz
e 50 -gravity Center -annotate 0 "Title: BW Descendants" -trim -bordercolor Blac
k -border 3 testArial.png
convert.exe: unable to read font `Ariel' @ warning/annotate.c/RenderType/964.
Image
snibgo's IM pages: im.snibgo.com

imPhil
Posts: 5
Joined: 2019-02-05T02:54:26-07:00
Authentication code: 1152

Re: Poor text rendering with Annotate in newer Magic++

Post by imPhil » 2019-02-05T10:32:53-07:00

Sorry, both samples were created from the same source at the same time -- any typos I the font name were in my editing of the code for the purpose posting here -- in real life it's user configured.

according to "convert -list font" it's this one
Font: Arial
family: Arial
style: Normal
stretch: Normal
weight: 400
glyphs: c:\windows\fonts\arial.ttf
Both new and old versions of convert list the same glyphs file, so I assume it's a subtle change in the rendering somewhere.

I don't knowingly have any version of free type except what comes with the respective versions of ImageMagik++.

imPhil
Posts: 5
Joined: 2019-02-05T02:54:26-07:00
Authentication code: 1152

Re: Poor text rendering with Annotate in newer Magic++

Post by imPhil » 2019-02-19T01:50:43-07:00

It's not the version of FreeType.

If I copy a CORE_RL_ttf.dll from a prebuilt v6 ImageMagick++ over the one in V7 I get the same poor results. ( I was surprised that doing this actually worked).

If I link My app to the V6 version of ImageMagick++ I get the better results. (only for release builds, for debug builds it blows up completely -- not surprisingly)

Post Reply