Skip to content
Related Articles

Related Articles

Improve Article
PHP | GmagickDraw settextencoding() function
  • Last Updated : 23 Jan, 2020

The GmagickDraw::settextencoding() function is an inbuilt function in PHP which is used to set the code set used for text annotations. These code sets tell the computer how to interpret raw zeroes and ones into real characters. Usually, they produce the same text but use different code sets.


GmagickDraw GmagickDraw::settextencoding( string $encoding )

Parameters:This function accepts a single parameter $encoding which holds the encoding.

Return Value: This function returns GmagickDraw object on success.

Exceptions: This function throws GmagickDrawException on error.

Below given programs illustrate the GmagickDraw::settextencoding() function in PHP:
Program 1:

// Create a GmagickDraw object
$draw = new GmagickDraw();
// Set the encoding
// Get the encoding
$encoding = $draw->gettextencoding();
echo $encoding;



Program 2:

// Create a new Gmagick object
$gmagick = new Gmagick('geeksforgeeks.png');
// Create a GmagickDraw object
$draw = new GmagickDraw();
// Draw rectangle for background
$draw->rectangle(-100, -1000, 800, 400);
// Set the fill color
// Set the font size
// Set the stroke color
// Set the encoding
// Create a rectangle
$draw->annotate(20, 110, 'This text is encoded using ' . $draw->gettextencoding());
// Use of drawimage function
// Display the output image
header("Content-Type: image/png");
echo $gmagick->getImageBlob();



My Personal Notes arrow_drop_up
Recommended Articles
Page :