承接 dngo-io/cover-creator 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

dngo-io/cover-creator

Composer 安装命令:

composer require dngo-io/cover-creator

包简介

PHP image generator with CSS

README 文档

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

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
wrap (optional) integer Integer value to wrap text. If disables auto-center selector.

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
background-url file Background file on the server. Exact path and file name. Should be PNG or JPG
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.

统计信息

  • 总下载量: 71
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 2
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-06-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固