Page 1 of 1

Difference in text rendering using convert

Posted: 2017-01-11T16:04:18-07:00
by tsmr
Hi all.

I use a simple bash script to resize and add some text + frame to an image.
A few days ago I noticed that when the font color is set to "red", the rendered text is quite blurred.
However when it is "white" then it looks alright.

Here is an example of the output: http://imgur.com/a/mmS0U

And the command to process the image:

Code: Select all

/usr/bin/convert /data/htdocs/hpsrv/cams/aircam-full.jpg -resize 800x450 -background black -gravity south -splice 0x20 -font /home/manager/fonts/open_sans/OpenSans-Regular.ttf -pointsize 14 -fill $tcolor -annotate +0+2 "A_TEXT" aircam-conv.jpg
And the original image info:

Code: Select all

aircam-full.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, baseline, precision 8, 1280x720, frames 3
Any ideas how to improve the rendering?

Thanks

Re: Difference in text rendering using convert

Posted: 2017-01-11T19:58:10-07:00
by fmw42
What is your IM version and platform? Please always provide that with questions.

Re: Difference in text rendering using convert

Posted: 2017-01-11T22:05:08-07:00
by tsmr
My bad.

OS:

Code: Select all

Debian Jessie (Linux hpsrv 3.16.0-4-amd64 #1 SMP Debian 3.16.36-1+deb8u2 (2016-10-19) x86_64 GNU/Linux)
ImageMagick:

Code: Select all

root@hpsrv:~$ /usr/bin/convert -version
Version: ImageMagick 6.8.9-9 Q16 x86_64 2016-11-26 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules OpenMP
Delegates: bzlib cairo djvu fftw fontconfig freetype jbig jng jpeg lcms lqr ltdl lzma openexr pangocairo png rsvg tiff wmf x xml zlib

Re: Difference in text rendering using convert

Posted: 2017-01-11T23:05:06-07:00
by fmw42
It seems to work fine for me on IM 6.9.7.3 Q16 Mac OSX. It does not seem to be blurred. Though the red text is going to be harder to read simply due to its contrast against black. I tested here for better visibility against a gray background.

Code: Select all

convert -size 800x450 xc:gray -gravity south -pointsize 14 -fill white \
-font /Library/fonts/OpenSans-Regular.ttf -annotate +0+2 "A_TEXT" text_white.jpg
Image

Code: Select all

convert -size 800x450 xc:gray -gravity south -pointsize 14 -fill red \
-font /Library/fonts/OpenSans-Regular.ttf -annotate +0+2 "A_TEXT" text_red.jpg
Image


Perhaps you need to upgrade IM or maybe only Freetype.

Re: Difference in text rendering using convert

Posted: 2017-01-12T21:25:56-07:00
by tsmr
Thank you for the response.
I'm thinking to split the process in two separate convert executions: first resize the image then add the black shape + text.
This way the drawn text will not be resized.
Do you reckon it will improve the output?

Re: Difference in text rendering using convert

Posted: 2017-01-12T22:17:11-07:00
by fmw42
Draw text only after resizing is the proper way. You do not need to do it in two convert steps. You can do that in one step with convert. You will have to choose a pointsize appropriate for the smaller image size.

However, from looking at your original code, that is what you are already doing. So I do not see that you need make any changes, nor will they help further.

I suspect you need to upgrade your version of IM and Freetype and perhaps lcms