The Wayback Machine - https://web.archive.org/web/20231211193233/https://www.geeksforgeeks.org/php-imagickdraw-setfontsize-function/
Open In App
Related Articles

PHP | ImagickDraw setFontSize() Function

Improve Article
Improve
Save Article
Save
Like Article
Like

The ImagickDraw::setFontSize() function is an inbuilt function in PHP which is used to set the font point size. It is used when annotating with text.
 

Syntax:  

bool ImagickDraw::setFontSize( $pointsize )

Parameters: This function accepts a single parameter $pointsize which is used to hold the value of point size.
Return Value: This function does not return any value.
Below programs illustrate the ImagickDraw::setFontSize() function in PHP:
Program 1:  

php




<?php
 
// Create an ImagickDraw object
$draw = new ImagickDraw();
 
// Set the image filled color
$draw->setFillColor('Green');
 
// Set the Font Size
$draw->setFontSize(30);
 
// Set the font family
$draw->setFontFamily('Ani');
 
// Set the text to be added
$draw->annotation(30, 40, "GeeksForGeeks");
   
// Create new Imagick object
$imagick = new Imagick();
 
// Set the image dimension
$imagick->newImage(250, 70, 'white');
 
// Set the image format
$imagick->setImageFormat("png");
 
// Draw the image
$imagick->drawImage($draw);
header("Content-Type: image/png");
 
// Display the image
echo $imagick->getImageBlob();
?>


Output: 

setFontSize

Program 2:  

php




<?php
 
// Create an ImagickDraw object
$draw = new ImagickDraw();
 
// Set the image filled color
$draw->setFillColor('red');
 
// Set the Font Size
$draw->setFontSize(40);
 
// Set the Font family
$draw->setFontFamily('Ubuntu-Mono');
 
// Set the text to be added
$draw->annotation(30, 170, "GeeksForGeeks");
 
// Set the image filled color
$draw->setFillColor('green');
 
// Set the font size
$draw->setFontSize(30);
 
// Set the font family
$draw->setFontFamily('Open-Sans-Light-Italic');
 
// Set the text to be added
$draw->annotation(30, 250, "Ubuntu-Mono");
 
// Create new Imagick object
$imagick = new Imagick();
 
// Set the image dimension
$imagick->newImage(350, 300, 'white');
 
// Set the image format
$imagick->setImageFormat("png");
 
// Draw the image
$imagick->drawImage($draw);
header("Content-Type: image/png");
 
// Display the image
echo $imagick->getImageBlob();
?>


Output: 

setFontSize

Reference: http://php.net/manual/en/imagickdraw.setfontsize.php 


Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 04 Oct, 2021
Like Article
Save Article
Previous
Next
Similar Reads
Complete Tutorials