tigra-image-library / ascii-art
此类可以生成看起来像给定图像的文本。它遍历给定图像的像素,并将每个区域的颜色值转换为字符文本,因此当你查看转换后的字符序列时,它看起来就像原始图像。结果文本可以可选地以格式化HTML的方式输出
1.0.1
2018-03-12 07:34 UTC
Requires
- php: ^5.4
- ext-gd2: *
- tigra-image-library/gd2-imaging: *
This package is auto-updated.
Last update: 2024-09-09 13:58:43 UTC
README
介绍
此类可以生成看起来像给定图像的文本。
它遍历给定图像的像素,并将每个区域的颜色值转换为字符文本,因此当你查看转换后的字符序列时,它看起来就像原始图像。
结果文本可以可选地以格式化HTML的方式输出,并以彩色显示。
示例输出
原始图像
图像裁剪后的ASCII艺术
代码示例
<?php use Tigra\AsciiArt\Generator; require_once('generator.php'); $x = new Generator('example.jpg'); $color = $x->getBackgroundColor()->getHexValue(); ?> <html> <head> <title>ASCII art demo</title> </head> <body bgcolor="#<?php echo $color; ?>"> <?php $x->setFontSize(6); $x->show(range("a", "z"), 0.25, true, true); ?> </body> </html>