Page 1 of 1
labels text encoding
Posted: 2013-04-11T04:34:52-07:00
by phobos
Hello!
Help me please, i have problem with encoding in labels!
try to use example
http://www.imagemagick.org/Usage/thumbnails/
Adding Borders
and i aad label "
Россия" (russian language) and get the following :
problem in the coding or in the font?
how to write label or caption on russian?
Re: labels text encoding
Posted: 2013-04-11T21:19:33-07:00
by anthony
You need to match the text encoding with the font. Typically you use a Unicode text with Unicode font.
The characters that appears on the image look like Unicode 'meta' characters, rather that a simpler 8-bit text format using russian meta characters (8-bit codes > 127).
You can use a command such as "iconv" on many machines to convert from practically any text format to some other text format (like unicode). I myself have used it to convert chinese 'gb' text to unicode for printing purposes.
A newer version of "iconv" is known as "recode"
In perl you can use something like the "Encode" library module.
Code: Select all
use Encode;
$text = 'Текст кириллица';
$text = encode("utf8", decode("cp1251", $text));
print "$text\n";
( I have no idea where I got this last from originally, I just saved it for future use).
Re: labels text encoding
Posted: 2013-04-13T11:49:15-07:00
by phobos
very thank you!
$mystr='тестовая строка';
Code: Select all
$mystr = iconv("windows-1251", "utf-8", $mystr);
$run = exec('convert thumbnail.gif \
-bordercolor black -border 3 -bordercolor white -border 2 \
\( -background black -fill white -pointsize 24 \
label:'.$mystr.' -trim +repage \
-bordercolor black -border 10 \
\) -gravity South -append \
-bordercolor black -border 10 -gravity South -chop 0x10 \
border_framework.gif',$out,$err);
it is option work good in php!