PHP code example of ange007 / poster-gen
1. Go to this page and download the library: Download ange007/poster-gen 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/ */
ange007 / poster-gen example snippets
use \PosterGen;
// Generate poster
$poster = ( new \PosterGen\PosterGen( [ ] ) )
->setSize( 1280, 720 )
->setBackgroundImage( __DIR__ . "/backgrounds/1.jpg" )
->setHorizontalAlignment( 'center' )
->setVerticalAlignment( 'center' )
->setFontShadow( '#333333', -2, 2 )
->setOverlayColor( '#FF0000' )
->setBorder( 'black', 1 )
// Title
->setFont( __DIR__ . "/fonts/Roboto-Regular" )
->setFontSize( 40 )
->setFontColor( '#FFFFFF' )
->addText( 'Microsoft buying GitHub' )
->addText( '' )
// Subtitle
->setFont( __DIR__ . "/fonts/Blogger_Sans.otf" )
->setFontSize( 20 )
->setFontColor( '#00FFFF' )
->addText( 'The deal is concluded' )
// Watermark
->setTextBackground( 'black', 50 )
->setHorizontalAlignment( 'right' )
->setVerticalAlignment( 'bottom' )
->setFontSize( 14 )
->setFontColor( '#FFFFFF' )
->setFontShadow( '' )
->setFontStroke( 'black' )
->addText( 'http://news.com' );
// Poster output
echo $poster->saveToBase64Image( );