dngo-io / cover-creator
PHP image generator with CSS
v1.3
2018-06-23 09:23 UTC
Requires
Requires (Dev)
- fzaninotto/faker: ~1.6
This package is not auto-updated.
Last update: 2024-11-10 06:01:57 UTC
README
DNGO Book Cover Creator
Usage;
First install package via composer;
composer require dngo-io/cover-creator
Sample code;
To use this package, you need to install PHP GD library to server
require ("vendor/autoload.php"); 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(); }
Available Selector Values
Availabile Config Values
the Generator
class takes third parameter as configs.
Important: If you wrap the line, auto-center is forced to false.
Error Handling
CoverCreator has 2 exceptions.
InvalidFileException
is thrown when the background image is not ok.
InvalidTypeException
is thrown when any of selector value is not valid.