ItalicではなくObliqueらしい。
https://cottala-becco.com/italic_and_oblique/
sample.php
<?php
declare(strict_types = 1);
/*
文字
*/
$text = "あああああ\nいいいいい";
$x = 0;
$y = 100;
$o_text = new ImagickDraw();
$o_text->setFillColor( new ImagickPixel('#0000ff') );
$o_text->setTextUnderColor( new ImagickPixel("rgba(204, 204, 204, 0.5)") ); //背景色(デバッグ用)
$o_text->setTextAntialias(false); //アンチエイリアス解除
$o_text->setFontSize(35);
$o_text->setFont('フォントファイルのパス');
$o_text->skewX(-15); //水平方向に傾ける
$o_text->setGravity( imagick::GRAVITY_NORTH ); //一旦中央寄せ
$o_text->annotation($x, $y, $text); //その後、位置を微調整
/*
背景画像合成
*/
$o_base = new Imagick('base.png');
$o_base->drawImage($o_text);
$o_base->setImageFormat('png');
$o_base->setImageCompressionQuality(0); // https://stackoverflow.com/questions/9710118/convert-multipage-pdf-to-png-and-back-linux/12046542#12046542
//ファイル保存
if (!true) {
$o_base->writeImage('hoge.png');
}
//直接表示
else {
header("Content-Type: image/png");
echo $o_base;
}
/*
メモリ解放
*/
$o_base->destroy();
$o_text->destroy();