bigweb/img2text

此包的最新版本(dev-master)没有可用的许可证信息。

dev-master 2015-11-11 10:02 UTC

This package is not auto-updated.

Last update: 2024-09-18 18:43:50 UTC


README

将图片转换为ASCII文本,可输出为HTML或ANSI终端。

另见 gif2text

示例

  1. img2text cat.jpg --color > with-color.html 演示
  2. img2text cat.jpg > without-color.html 演示
  3. img2text cat.jpg --ansi 它会是这样:

安装

$ composer require bigweb/img2text

用法

Usage:
  img2text <imgfile> [--maxLen=<n>] [--fontSize=<n>] [--color] [--ansi] [--bgcolor=<#RRGGBB>]
  img2text (-h | --help)

Options:
  -h --help             show this screen.
  --ansi                output an ANSI rendering of the image
  --color               output a colored HTML rendering of the image.
  --fontSize=<n>        sets font size (in pixels) when outputting HTML,
                        default: 7
  --maxLen=<n>          resize image so that larger of width or height matches
                        maxLen, default: 100px
  --bgcolor=<#RRGGBB>   if specified, is blended with transparent pixels to
                        produce the output. In ansi case, if no bgcolor set, a
                        fully transparent pixel is not drawn at all, partially
                        transparent pixels drawn as if opaque

您也可以像这样在您的应用程序的任何地方使用它

use Bigweb\Img2text\Img2text;

$options = [
        'ansi'     => ,
        'color'    => 1,
        'fontSize' => 7,
        'maxLen'   => 100,
    ];
$img = new Img2text('imageFilePath', $options);
echo $img->render();

感谢

  1. 使用 https://github.com/docopt/docopt.php 创建漂亮的命令行界面
  2. 使用 https://github.com/Intervention/image 处理图片
  3. 感谢 @hit9,此项目是从 https://github.com/hit9/img2txt 窃取的

许可证

BSD。