定制 jtar/poster 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

jtar/poster

Composer 安装命令:

composer require jtar/poster

包简介

poster generator. 基于GD库的PHP海报生成器,返回base64

README 文档

README

基于 GD 库,生成海报!

安装

composer require cshaptx4869/poster

示例

run.php

<?php

require_once './vendor/autoload.php';

use Fairy\Poster;

try {
    $poster = new Poster('./images/bg.png');
    $poster->image('./images/avatar.jpg', 94, 52, 82, 82, true)
        ->image('./images/service.png', 40, 310, 665, 566)
        ->image('./images/mini.jpg', 518, 1070, 180, 180)
        ->text('白開水', 26, 220, 86, '150, 151, 150')
        ->text('我们感情深,帮忙助力行不行', 35, 30, 210, '255, 255, 255')
        ->text('单次4小时,专业保洁师为您解决全屋精细保洁', 24, 30, 270, '255, 255, 255')
        ->text('&#165; 0.00', 40, 50, 946, '255, 0, 0')
        ->text('原价 &#165;199', 20, 50, 990, '150, 151, 150')
        ->line(44, 980, 170, 980, '150, 151, 150', 2)
        ->output();
    exit();
} catch (\Exception $e) {
    file_put_contents('./error.log', $e->getMessage(), FILE_APPEND);
}

方法说明

  • new Poster()
/**
 * 生成一张背景图
 * @param string $backgroundImage 背景图片
 * @throws \Exception
 */
public function __construct($backgroundImage)
  • image()
/**
 * 设置图像
 * @param string $image 本地、网络、二进制图片
 * @param int $x 起始x坐标
 * @param int $y 起始y坐标
 * @param int $width 所占宽度
 * @param int $height 所占高度
 * @param bool $circle 是否需要转成圆形
 * @return $this
 * @throws \Exception
 */
public function image($image, $x, $y, $width, $height, $circle = false)
  • text()
/**
 * 设置文字
 * @param string $text 文本
 * @param float $size 字体大小
 * @param int $x 起始x坐标(注意是字体左下角的坐标)
 * @param int $y 起始y坐标
 * @param string $rgb rgb颜色字符串 逗号隔开
 * @param string $fontFamily 字体
 * @return $this
 * @throws \Exception
 */
public function text($text, $size, $x, $y, $rgb = '255,255,255', $fontFamily = null)
  • line()
/**
 * 设置线条
 * @param int $x1 第1个点x坐标
 * @param int $y1 第1个点y坐标
 * @param int $x2 第2个点x坐标
 * @param int $y2 第2个点y坐标
 * @param string $rgb rgb颜色字符串 逗号隔开
 * @param int $weight 线条粗细
 * @return $this
 * @throws \Exception
 */
public function line($x1, $y1, $x2, $y2, $rgb = '255,255,255', $weight = 1)
  • output()
/**
 * 输出
 * @param null $filename 保存图片名称 不写则浏览器输出
 */
public function output($filename = null)

其他

如果要生成二维码,推荐使用 endroid/qr-code 包。生成二维码后再调用本包的 image() 方法即可生成带有二维码的海报。

jtar/poster 适用场景与选型建议

jtar/poster 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.44k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 12 月 11 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「gd」 「poster」 「海报」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 jtar/poster 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 jtar/poster 我们能提供哪些服务?
定制开发 / 二次开发

基于 jtar/poster 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2021-12-11