1. Go to this page and download the library: Download 53ny4/og-image 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/ */
53ny4 / og-image example snippets
$og = new OgImageGenerator();
$og->setBackgroundImage('src/assets/images/bg.png');
$og->createImage();
$text = (new TextElement())
->setText('OgImage')
->setFontSize(75)
->setFontColor('#ffffff')
->setFontPath('src/assets/fonts/BebasNeue-Regular.ttf')
->setBgOpacity(50)
->setMargin(50)
->setPosition('top', 'center');
$text2 = (new TextElement())
->setText('Hello World!')
->setFontSize(50)
->setFontColor('#ffffff')
->setFontPath('src/assets/fonts/BebasNeue-Regular.ttf')
->setBgColor('#000000')
->setBgOpacity(50)
->setPosition(470, 'center');
$text3 = (new TextElement())
->setText('Lorem ipsum dolor sit amet, consectetur adipiscing elit. ')
->setFontSize(25)
->setFontColor('#ffffff')
->setFontPath('src/assets/fonts/BebasNeue-Regular.ttf')
->setBgOpacity(50)
->setPosition(539, 'center');
$watermark = (new Watermark())
->setWatermarkPath('src/assets/images/watermark.png')
->setSize(100)
->setMargin(10)
->setPosition('bottom', 'right');
$og->addWatermark($watermark);
$og->addText($text);
$og->addText($text2);
$og->addText($text3);
$og->render();
use s3ny4\OgImage\OgImageGenerator;
use s3ny4\OgImage\TextElement;
use s3ny4\OgImage\Watermark;
// Create generator instance
$og = new OgImageGenerator(1200, 630);
// Add background image
$og->setBackgroundImage('path/to/background.jpg');
// Add text
$text = (new TextElement())
->setText('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam accumsan sed lacus venenatis eleifend. Aenean ipsum turpis, faucibus nec maximus sit amet, lobortis vel nisl. ')
->setPosition('center', 'center')
->setFontPath('src/assets/fonts/font.ttf')
->setFontSize(36)
->setFontColor('#ffffff')
->setBgOpacity(50)
->setBgColor('#ff0000');
$og->addText($text);
// Add watermark
$watermark = (new Watermark('src/assets/images/logo.png'))
->setPosition('top', 'center')
->setMargin(50)
->setSize(150)
->setOpacity(50);
$og->addWatermark($watermark);
// output image to the browser
$og->render();
// or save to file
// $og->render('og-image.png');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.