PHP code example of andrewgjohnson / agjgd

1. Go to this page and download the library: Download andrewgjohnson/agjgd library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

andrewgjohnson / agjgd example snippets




use AndrewGJohnson\AgjGd;

$image = imagecreatetruecolor(600, 300);
$font  = 'NotoSans-Regular.ttf';

// Fill the image with a red-to-blue gradient
AgjGd::imagegradientrectangle(
    $image,
    0,
    0,
    imagesx($image) - 1,
    imagesy($image) - 1,
    AgjGd::imagecolorallocatefromstring($image, 'red'),
    AgjGd::imagecolorallocatefromstring($image, 'blue')
);

// Wrap the text so that it does not overflow, then write it as blurred yellow text
$text = AgjGd::linebreaksfortext(30, 0, $font, 'Hello from AgjGd!', 500);

AgjGd::imagefttextfilter(
    $image,
    30,
    0,
    50,
    150,
    AgjGd::imagecolorallocatefromstring($image, 'yellow'),
    $font,
    $text,
    [],
    10
);

header('Content-Type: image/png');
imagepng($image);