4th Street Bar Hive-Bar

Hive-Bar Powered by Hive beta-fdb5b5b

Community post

Book Cover Creator for DNGO

DNGO Book Cover Creator

https://steemitimages.com/0x0/https://cdn.steemitimages.com/0x0/https://cdn.utopian.io/posts/5721d1d68749bd29523f8f6aedeef0e1168d01.png

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

Name Value Description
font-size integer Font size in px. Only integer values
font-type file Font file on the server. Exact path and file name.
text-color array text color as RGB
left integer Margin Left value of text
top integer Margin Top value of text
background-url file Backgroun 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.

Name Value Description
auto-center bool Enable text center on image
angle integer Angle of the text on image
header string default 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

21 upvotes $16.61

Replies (5)

Review before signing

Posting as . Signing with . Keychain permission: Posting. Hive Keychain will ask you to approve this action next.


  
Technical details

Operation fingerprint: