fayyaztech/print_text_on_image

这个库可以帮助您在图像上打印文本和图像,如证书、身份证签名和条形码二维码

1.0.3 2023-02-11 13:11 UTC

This package is not auto-updated.

Last update: 2024-09-21 20:56:05 UTC


README

关于

  • 任何人都可以使用这个库来创建打印的证书和身份证横幅。
  • 简单易用的方式将其集成到现有项目中
  • 目前我还没有提供多色文本,只有黑色文本可用
  • 我正在努力改进,很快就会提供

安装

composer require fayyaztech/print_text_on_image

示例代码

  • setContent是一个包含Text和图像类的数组
  • 因此您可以在同一背景上打印多个文本和图像
  • 如条形码和二维码
  • PrintTextOnImagePrintTextOnImage将为您提供预览、保存和直接下载图像的选项

configImage参数

     * @param String $imagePath image file path
     * @param int $x horizontal place on background image
     * @param int $y vertical place on background image
     * @param int $width image width
     * @param int $height image height
     * @param int $opacity image opacity/visibility

ConfigText

     * @param String $textContent text you want to print on image
     * @param Int $fontSize font size of that text
     * @param Int $angle rotation of text
     * @param Bool $textHorizontalCenter user can make text center auto by added true parameter
     * @param Int $x horizontal position of text
     * @param Int $y vertical position of text
     * @param $color $color color is black for now we will provide color option soon
     * @param String $font_location custom font if you want other wise default is arial

PrintTextOnImagePrintTextOnImage

 
     * @param String $backgroundImagePath background image file path | remote url not allow | jpeg and png support
     * @param Array $data data should be an array of ConfigText and ConfigImage class
     * @param String $imageOptions download|preview|save
     * @param String $savePath if you want to save file on server directory. provide the path here and $imageOption must be save
     

查看下面的代码

<?php

require_once 'vendor/autoload.php';

use Fayyaztech\PrintTextOnImage\ConfigImage;
use Fayyaztech\PrintTextOnImage\ConfigText;
use Fayyaztech\PrintTextOnImage\PrintTextOnImage as PrintTextOnImagePrintTextOnImage;

$setContent = [
    new ConfigText('Text on image', 30, 60, 30,0,true),
    new ConfigText('this is 2nd text', 30, 100, 10),
    new ConfigImage('php.png', 150, 100, 60, 30, 70),
];


$test = new PrintTextOnImagePrintTextOnImage('./white.png', $setContent, 'preview');
$test->generate();

特别感谢

文本居中于背景图像