定制 christianberkman/imagick-text-box 二次开发

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

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

christianberkman/imagick-text-box

最新稳定版本:v1.2

Composer 安装命令:

composer require christianberkman/imagick-text-box

包简介

Add a simple text box to an image using PHP's Imagick Library

README 文档

README

Add a simple text box to an image using PHP's Imagick Library

Example

Installation

Composer:

composer install christianberkman/imagick-text-box

Usage

use \Imagick;
use ImagickTextBox\ImagickTextBox;

$image = new Imagick()->readImage('your-image.php');
$textBox = new ImagickTextBox($image);
$textBox->string = 'Hello World';
$textBox->draw(Imagick::GRAVITY_NORTHWEST);

Also see example.php with a more detailed example of usage.

Public methods

  • void __construct(Imagick $image) Construct the class and initialize ImagickDraw objects
  • void draw(int $gravity = Imagick::GRAVITY_SOUTHEST) draw the textbox on the Imagick $image object
  • bool textFits() Returns if the text fits on the given image

Public Properties

Imagick Objects

All these objects are fully accessible and can be manipulated to set desired fill color, font size, etc.

  • Imagick $image Your image object
  • ImagickDraw $text Text object, initialized by ImagickTextBox
  • ImagickDraw $box Box object, initializes by ImagickTextBox

Configuration

  • string $string = 'Hello World' The string of text to print
  • int $margin_x = 10 Margin (px) from the side (does not apply to north, south, center)
  • int $margin_y = 10 Margin (px) from the top/bottom (does not apply to west, east, center)
  • int $padding = 5 Padding (px) of text inside text box
  • int $gravity = Imagick::GRAVITY_SOUTHWEST Imagick Gravity Constant
  • float $heightFactor = 0.6 Height factor to use. By using the default font, a factor of 1 produces a text box with a lot of vertical whitespace, 0.6 seems to do the trick.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-06-04