PHP | GmagickDraw gettextencoding() Function
Last Updated :
29 Jan, 2020
The GmagickDraw::gettextencoding() function is an inbuilt function in PHP which is used to get 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:
string GmagickDraw::gettextencoding( void )
Parameters: This function doesn’t accept any parameters.
Return Value: This function returns a string value containing the text encoding used.
Exceptions: This function throws GmagickDrawException on error.
Below given programs illustrate the GmagickDraw::gettextencoding() function in PHP:
Program 1:
<?php
$draw = new GmagickDraw();
$textEncoding = $draw ->gettextencoding();
echo $textEncoding ;
?>
|
Output:
// Empty string which is the default value
Program 2:
<?php
$draw = new GmagickDraw();
$draw ->settextencoding( 'utf-8' );
$textEncoding = $draw ->gettextencoding();
echo $textEncoding ;
?>
|
Output:
utf-8
Used Image:
Program 3:
<?php
$gmagick = new Gmagick( 'geeksforgeeks.png' );
$draw = new GmagickDraw();
$draw ->setFillColor( '#0E0E0E' );
$draw ->rectangle(-10, -10, 800, 400);
$draw ->setFontSize(40);
$draw ->setfillcolor( 'white' );
$draw ->settextencoding( 'UTF-8' );
$draw ->annotate(50, 50,
'This line is encoded with '
. $draw ->getTextEncoding());
$draw ->settextencoding( 'UTF-32' );
$draw ->annotate(50, 100,
'This line is encoded with '
. $draw ->getTextEncoding());
$gmagick ->drawImage( $draw );
header( "Content-Type: image/png" );
echo $gmagick ->getImageBlob();
?>
|
Output:
Reference: https://www.php.net/manual/en/gmagickdraw.gettextencoding.php
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...