Book Cover Creator for DNGO

in #utopian-io6 years ago (edited)

DNGO Book Cover Creator

This is a package for DNGO Book Cover Image Creator Task

Dngo books is Dngo’s first project that is specifically intended to incentivise people to collectively create multilingual audiobook archives – mainly to serve people with a visual impairment.

Read more on introduction post.

Package Usage;

To use this package, you need to install PHP GD library to server

First install package via composer;

composer require dngo-io/cover-creator

Sample code;

require ("vendor/autoload.php");


use DngoIO\CoverCreator\Generator;

$selectors = [
        '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
    ];


try {
    $generator = new Generator("My Text On Image", $selectors);
    $generator->generate();
}catch (\Exception $e) {
    echo $e->getMessage();
}

Available Selector Values

NameValueDescription
font-sizeintegerFont size in px. Only integer values
font-typefileFont file on the server. Exact path and file name.
text-colorarraytext color as RGB
leftintegerMargin Left value of text
topintegerMargin Top value of text
background-urlfileBackgroun file on the server. Exact path and file name. Should be PNG or JPG

Availabile Config Values

the Generator class takes third parameter as configs.

NameValueDescription
auto-centerboolEnable text center on image
angleintegerAngle of the text on image
headerstringdefault value of header when image generated. default is Content-type: image/jpeg

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.

Pull Request

https://github.com/dngo-io/cover-creator/pull/1

Sort:  

Hi there, thanks for the contribution.

  • It could be awesome if you give some informationabout dngo.io before going deep on the project details. In the current post structure, I have no idea about dingo.io (as a reader doesn't know about it.) but I see there is a cover generator library for it.

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]

Hello @emrebeyler,
Thanks for comment. I have put an explanation and url of the introduction post of DNGO.

Hey @bencagri
Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Contributing on Utopian
Learn how to contribute on our website or by watching this tutorial on Youtube.

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!