I have to generate text-images dynamically and the size of the image have to fit the text-size of course.
That's my code so far:
Code: Select all
$mw=NewMagickWand();
$dw=NewDrawingWand();
$pw['white']=NewPixelWand();
$pw['black']=NewPixelWand();
$pw['red']=NewPixelWand();
PixelSetColor($pw['white'], 'white');
PixelSetColor($pw['red'], '#C10600');
PixelSetColor($pw['black'], 'black');
MagickNewImage($mw, 200, 30, '#C10600');
// MagickPaintTransparentImage($mw, $pw['red']);
MagickSetFormat($mw, 'png');
DrawSetFont($dw, dirname(__FILE__).'/../ClarendonLTStd-Bold.pfb');
DrawSetFontSize($dw, self::FONT_SIZE);
DrawSetStrokeColor($dw, $pw['black']);
DrawSetStrokeWidth($dw, 0.8);
DrawSetStrokeOpacity($dw, 0);
DrawSetFillColor($dw, $pw['white']);
MagickAnnotateImage($mw, $dw, 0, self::FONT_SIZE, 0, 'STARTSEITE');
header('Content-type: image/png');
MagickEchoImageBlob($mw);
die;
As you can see the image itself is bigger than the text.
How can I resize the image so that it fits the generated text?
Thank you!