node ascii 转换_使用Node.js将图像转换为ASCII Art

小灰灰 2023-02-22 01:24 119阅读 0赞

node ascii 转换

ASCII Art

There are many people out there that don’t appreciate ASCII art; we call those people “idiots”. ASCII art has been used forever and remains, in my opinion, a feat of programming and creativity. There’s a project called image-to-ascii which doesn’t just create ascii art but does so from an image of your choosing. Baller!

有很多人不喜欢ASCII艺术。 我们称这些人为“白痴”。 在我看来,ASCII艺术已被永久使用,并且仍然是编程和创造力的壮举。 有一个名为“ 图像转ascii”的项目,它不仅可以创建ascii艺术,还可以根据您选择的图像来创建。 鲍尔!

Assuming you’ve installed dependencies, outputting an image to ASCII art in the console is fairly simple:

假设您已经安装了依赖项,则在控制台中将图像输出为ASCII图像非常简单:

  1. var ImageToAscii = require('image-to-ascii');
  2. ImageToAscii(__dirname + '/logo.png', function(err, converted) {
  3. console.log(err || converted);
  4. });

Short bit of code for a cool effect. You’ll want to size the image down to less than 200px for best display and even then the ASCII output within the console looks excellent. As I mentioned in Show Images in Console with Node.js console-png, adding graphical elements to the console can be a nice touch and enhancement from bland text!

简短的代码可带来炫酷效果。 您可能希望将图像缩小到小于200像素,以获得最佳显示效果,即使如此,控制台内的ASCII输出看起来也很出色。 正如我在使用Node.js console-png在控制台中显示图像中提到的那样,向控制台添加图形元素可以使平淡的文本变得很不错,并且得到了增强!

翻译自: https://davidwalsh.name/convert-image-ascii-art

node ascii 转换

发表评论

表情:
评论列表 (有 0 条评论,119人围观)

还没有评论,来说两句吧...

相关阅读

    相关 ASCII编码以及转换

    上个世纪60年代,美国制定了一套字符编码,对英语字符与二进制位之间的关系,做了统一规定,即ASCII码。ASCII码一共规定了128个字符的编码。 ![在这里插入图片描述]