Cyrillic text from the image

PerlMagick is an object-oriented Perl interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning PerlMagick.
Post Reply
YouPict.Ru
Posts: 9
Joined: 2011-10-26T20:42:14-07:00
Authentication code: 8675308

Cyrillic text from the image

Post by YouPict.Ru »

Hi all!

Cyrillic text from the image. My decision.

Code: Select all

use Encode;
use Image::Magick;
$image = Image::Magick->new;
$image->Set(size=>'250x250');
$image->ReadImage('canvas:red');
$image->Border(width=>1, height=>1, bordercolor=>'black');
$text = 'Текст кириллица';
$text = encode("utf8", decode("cp1251", $text));
$image->Annotate(font=>'arial.ttf', pointsize=>18, fill=>'green', gravity=>'center', text=>$text);
$image->Set (compression=>'JPEG', quality=>80);
$image->Write ("name.jpg");
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Cyrillic text from the image

Post by anthony »

The handling for cyrillic text to UTF8 in perl is useful to know!

But the text into that first assignment already appears to be utf8, persumably because you posted it on a utf8 website :-)
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply