PHP | GmagickDraw settextencoding() function
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.
Syntax:
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:
<?php
$draw = new GmagickDraw();
$draw ->settextencoding( 'utf-32' );
$encoding = $draw ->gettextencoding();
echo $encoding ;
?>
|
Output:
utf-32
Program 2:
<?php
$gmagick = new Gmagick( 'geeksforgeeks.png' );
$draw = new GmagickDraw();
$draw ->rectangle(-100, -1000, 800, 400);
$draw ->setfillcolor( 'white' );
$draw ->setfontsize(30);
$draw ->setstrokecolor( 'green' );
$draw ->settextencoding( 'utf-8' );
$draw ->annotate(20, 110, 'This text is encoded using ' . $draw ->gettextencoding());
$gmagick ->drawImage( $draw );
header( "Content-Type: image/png" );
echo $gmagick ->getImageBlob();
?>
|
Output:
Reference: https://www.php.net/manual/en/gmagickdraw.settextencoding.php
Last Updated :
23 Jan, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...