masokky/quotemaker

创建引用图片的简单库

v1.0.0 2018-10-22 05:09 UTC

This package is auto-updated.

Last update: 2024-09-15 16:46:53 UTC


README

QuoteMaker 是一个简单的创建引用图片的库

示例结果

Example Result

安装

composer require masokky/quotemaker

如果你不使用 composer,点击这里 使用简单安装

使用方法

<?php
require "./vendor/autoload.php";
use masokky\QuoteMaker;
try{
  $text = "the cruelest crime is giving false hope without love";
    (new QuoteMaker)
      ->setBackgroundFromUnsplash(["b353e61a07cc0068080258kc0294ks85042f2560d6223366500a2aa30ff28052"],"heart")
      ->quoteText($text)
      ->watermarkText("Mas Okky")
      ->toFile("result.jpg");
}catch(Exception $e){
  echo $e->getMessage();
}

可用方法

setBackground($path)

  • $path (字符串) - 背景图片的位置

setBackgroundFromUnsplash($client_id,$keyword)

你可以搜索并使用来自 unsplash.com 的图片
在使用此功能之前,你应该创建应用程序以获取访问 API 的 "client_id"
由于每个 "client_id" 每小时的限制,因此你可以添加两个或更多 "client_id" 来提高限制

  • $client_id (数组) - unsplash 应用程序的访问密钥
  • $keyword (字符串) - 搜索图片的关键字,默认 random

quoteText($text)

  • $text (字符串) - 设置引用文本。使用 \n 添加换行符

setQuoteFont($path)

  • $path (字符串) - 设置自定义引用字体*

setQuoteFontSize($size)

  • $size (整数) - 设置自定义引用字体大小*

watermarkText($text)

  • $text (字符串) - 设置水印文本,默认 null

setWatermarkFont($path)

  • $path (字符串) - 设置自定义水印字体*

setWatermarkFontSize($size)

  • $size (整数) - 设置自定义水印字体大小*

toScreen()

将结果输出到屏幕

toFile($file)

将结果保存到图像文件

*默认查看示例结果

欢迎开发和维护此库