IonicaBizau/image-to-ascii

Better example explanation?

Closed this issue · 3 comments

Hi!

I'd love to try out this program, alas I know little about JS. I tried to follow as closely as possible your instructions.

I managed to install it and I copy & pasted your example to a file named test.

Installing I got this message:

npm WARN engine pngjs@0.4.0: wanted: {"node":"0.8.x"} (current: {"node":"0.12.2","npm":"2.7.5"})
image-to-ascii@1.3.0 node_modules/image-to-ascii
├── tmp@0.0.24
├── pngjs@0.4.0
├── couleurs@2.0.0 (x256@0.0.2)
├── gm@1.17.0 (array-series@0.1.5, array-parallel@0.1.3, through@2.3.7, debug@0.7.0)
└── request@2.49.0 (caseless@0.8.0, json-stringify-safe@5.0.0, aws-sign2@0.5.0, forever-agent@0.5.2, stringstream@0.0.4, oauth-sign@0.5.0, tunnel-agent@0.4.0, node-uuid@1.4.3, qs@2.3.3, mime-types@1.0.2, tough-cookie@1.1.0, combined-stream@0.0.7, http-signature@0.10.1, form-data@0.1.4, hawk@1.1.1, bl@0.9.4)

Is that OK?

I changed the example image to one that exists on my disk. Then I run node test and I get:

module.js:338
    throw err;
          ^
Error: Cannot find module '../lib/index'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/Users/joseph/Desktop/test.js:1:82)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)

What am I doing wrong? Obviously ../lib/index does not exist in my home, where is it located?

Thanks!

Hey!

Thanks for bringing this in attention. ❇️

The following should work:

var ImageToAscii = require("image-to-ascii");

ImageToAscii(__dirname + "/some-image.png", function(err, converted) {
    console.log(err || converted);
});

Also, you can pass directly a link to image:

var ImageToAscii = require("image-to-ascii");

ImageToAscii("https://avatars1.githubusercontent.com/u/5038142?v=3&s=460", function(err, converted) {
    console.log(err || converted);
});

The code above will output:

screenshot from 2015-05-16 22 03 33

If you like, you can create a pull request with the fix in the documentation. ✨

Hey that's me!

Thanks for the example, that works perfectly.

I'll submit a pull request shortly.

Cheers,

GV

Thanks for fixing! 🍰