PHP code example of dngo-io / cover-creator

1. Go to this page and download the library: Download dngo-io/cover-creator 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/ */

    

dngo-io / cover-creator example snippets





use DngoIO\CoverCreator\Generator;

$text1 = [
        'font-size' => 18,  //px
        'font-type' => __DIR__ . '../assets/Roboto-Regular.ttf', //path of ttf file on server
        'text-color' => [61,183,228],
        'left' => 0,
        'top' => 0,
        'background-url' => __DIR__ . '../assets/background.jpg' //path of the png
    ];

$text2 = [
        'font-size' => 12,  //px
        'font-type' => __DIR__ . '../assets/Roboto-Italic.ttf', //path of ttf file on server
        'text-color' => [61,183,228],
        'left' => 50,
        'top' => 30,
    ];


$config = [
        'auto-center' => true,
        'angle' => 0,
        'header' => 'Content-type: image/jpeg',
    ];
  
try {
    $generator = new Generator();
    $generator->setConfig($config); //or new Generator($config)
    $generator->addLine('My First Text', $text1);
    $generator->addLine('Second ine Text', $text2);
    $generator->generate();
}catch (\Exception $e) {
    echo $e->getMessage();
}