setFontWeight

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
gpalmer711

setFontWeight

Post by gpalmer711 »

Has anyone been able to get the setFontWeight method of the ImagickDraw class to function at all?

The following snippet works fine other than the setFontWeight part.

Code: Select all

<?php
// Set the base variables and get any that have been passed in
$textColor = "#000000";
$fontSize = 20;
$line1 = "Example";
$strFont = "fonts/MyriadPro-Bold.otf";

// Generate the images used to compose the template
$imgButtonText = new Imagick();

//Create new draw instance and set up the font settings
$imgTitle = new ImagickDraw();
//$imgTitle->setFont($strFont);
$imgTitle->setFont('DejaVu-Serif-Condensed-Bold');
$imgTitle->setFontWeight(100);
$imgTitle->setFontSize((int)$fontSize);
$imgTitle->setFillColor($textColor);

$imgTitle->setGravity(Imagick::GRAVITY_CENTER);

// Set the size of the text box and the bg color/transparency
$imgButtonText->setSize(153,58);
$imgButtonText->newImage(153, 58, "white");
$imgButtonText->paintTransparentImage("white", 0.0, 0.0);

// Add text to the textbox
$imgButtonText->annotateImage($imgTitle,0,0,0,$line1);
$imgButtonText->setImageFormat('png');
//output the new image
header('Content-type: image/png');
echo $imgButtonText;

//destroy the new image
$imgButtonText->destroy();
?>
Post Reply