labels text encoding

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
phobos
Posts: 13
Joined: 2013-04-07T03:07:18-07:00
Authentication code: 6789

labels text encoding

Post 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
Image
and i aad label "Россия" (russian language) and get the following :

Image
Image

problem in the coding or in the font?
how to write label or caption on russian? :(
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: labels text encoding

Post 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).
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
phobos
Posts: 13
Joined: 2013-04-07T03:07:18-07:00
Authentication code: 6789

Re: labels text encoding

Post 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!
Post Reply