guo-yu / ascii Goto Github PK
View Code? Open in Web Editor NEWconvert pictures to ascii arts based on node-canvas
License: MIT License
convert pictures to ascii arts based on node-canvas
License: MIT License
I want to render an ASCII representation of an image stored as a nodejs buffer. Will this library work for this purpose? How would I bypass the file read operation and pass a buffer in directly?
Heyo
Awesome project, love it! it works as expected!
Just a question tho, what if I want to make it work with external files ?
Like, giving it an url as url parameter.
This would be rad.
Thanks!
TypeError: Ascii is not a constructor
at download.image.then (/home/quickbot/cmd/asciiimage.js:15:19)
at
my code
`
let attachment = message.attachments.first().url;
const options = {
url: attachment,
dest: 'image' // Save to /path/to/dest/image.jpg
}
download.image(options)
.then(({ filename, image }) => {
let pic = new Ascii(image/filename);
pic.convert(function(err, result) {
message.channel.send(result);
})
}).catch((err) => {
message.channel.send("Error occured, please retry.");
console.log(err);
});
Using the code in the readme.md file, it writes the error.
`
var pic = new Ascii('https://i.imgur.com/rNd3mIH.png');
^
TypeError: Ascii is not a constructor
at Object. (C:\Users\Daniel.DESKTOP-HNMIRLQ\Desktop\random projects\image to ascii\index.js:2:11)
?[90m at Module._compile (node:internal/modules/cjs/loader:1101:14)?[39m
?[90m at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)?[39m
?[90m at Module.load (node:internal/modules/cjs/loader:981:32)?[39m
?[90m at Function.Module._load (node:internal/modules/cjs/loader:822:12)?[39m
?[90m at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)?[39m
?[90m at node:internal/main/run_main_module:17:47?[39m
`
Anyone have an online demo with simple upload image form?
[root@localhost demo]# node index.js
/root/project/ascii-master/index.js:37
ctx.drawImage(pic, 0, 0, pic.width, pic.height);
^
Error: Image given has not completed loading
at /root/project/ascii-master/index.js:37:17
at /root/project/ascii-master/index.js:21:13
at fs.js:266:14
at Object.oncomplete (fs.js:107:15)
When I tried out the example in the README just get an error
/home/agirorn/code-play/logo/logo.js:2
var pic = new Ascii('logo.png');
^
TypeError: Ascii is not a constructor
at Object.<anonymous> (/home/agirorn/code-play/logo/logo.js:2:11)
at Module._compile (internal/modules/cjs/loader.js:936:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
at Module.load (internal/modules/cjs/loader.js:790:32)
at Function.Module._load (internal/modules/cjs/loader.js:703:12)
at Function.Module.runMain (internal/modules/cjs/loader.js:999:10)
at internal/main/run_main_module.js:17:11
➜ logo node
Welcome to Node.js v12.10.0.
Type ".help" for more information.
> var Ascii = require('ascii');
undefined
> Ascii.toString()
'[object Object]'
>
原文出自:
基于canvas将图片转化成字符画 | 前端手记 http://www.cssha.com/img2txt-canvas
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.