perl -e 'binmode(STDOUT, ":utf8"); \
print "\x{201C}Unicode \x{2018}\x{263A}\x{2019} Please\x{201D}";' |\
convert -background lightblue -fill blue -pointsize 36 \
label:@- label_unifun.gif
I am trying to follow ImageMagick documentation to achieve the same result in PHP. However, so far with no result. This is what I have:
$draw = new ImagickDraw();
$draw->setTextEncoding('UTF-8');
$draw->setFontSize(52);
$draw->setFont("font.otf");
$draw->setStrokeAntialias(TRUE);
$draw->setTextAntialias(TRUE);
$draw->annotation(20, 50, "\x{201C}Unicode \x{2018}\x{263A}\x{2019} Please\x{201D}");
$canvas = new Imagick();
$canvas->newImage(1000, 500, "red");
$canvas->drawImage($draw);
$canvas->setImageFormat('png');
header("Content-Type: image/png");
echo $canvas;
But it just prints \x{201C}Unicode \x{2018}\x{263A}\x{2019} Please\x{201D}.
PHP will do the escaping for you when passing it to ImageMagick, just insert your Unicode characters un-escaped into your string: