ajay-gandhi / asciify-image Goto Github PK
View Code? Open in Web Editor NEWConvert images to ASCII art
Convert images to ASCII art
Hi, I've been using your library to log images under Node.js with good results, very helpful indeed when debugging WebGL related code running in headless mode.
However, a problem with this library is that it lists npm
as a dependency which while unused, is just too heavy for our app installs. If you could move npm
to devDependencies
(or completely remove it from package.json) things would look much better.
https://github.com/ajay-gandhi/asciify-image/blob/master/package.json#L13
Hello there, unfortunately, asciify-image can’t be installed on current node/npm on OSX 10.12.1 … some problem with lwip and/or lodash. Could you maybe look into this? Thank you very much.
npm install asciify-image
[email protected] install node_modules/asciify-image/node_modules/lwip
node-gyp rebuild
CXX(target) Release/obj.target/lwip_decoder/src/decoder/init.o
In file included from ../src/decoder/init.cpp:1:
In file included from ../src/decoder/decoder.h:13:
In file included from ../../nan/nan.h:182:
../../nan/nan_maybe_43_inl.h:221:17: warning: 'CloneElementAt' is deprecated [-Wdeprecated-declarations]
return array->CloneElementAt(GetCurrentContext(), index);
^
/Users/and1/.node-gyp/7.0.0/include/node/v8.h:3056:36: note: 'CloneElementAt' has been explicitly marked deprecated here
MaybeLocal<Object> CloneElementAt(Local<Context> context,
^
In file included from ../src/decoder/init.cpp:1:
In file included from ../src/decoder/decoder.h:13:
In file included from ../../nan/nan.h:188:
In file included from ../../nan/nan_new.h:189:
../../nan/nan_implementation_12_inl.h:40:29: warning: 'New' is deprecated [-Wdeprecated-declarations]
return v8::BooleanObject::New(value).As<v8::BooleanObject>();
^
/Users/and1/.node-gyp/7.0.0/include/node/v8.h:4048:56: note: 'New' has been explicitly marked deprecated here
V8_DEPRECATED("Pass an isolate", static Local<Value> New(bool value));
^
In file included from ../src/decoder/init.cpp:1:
In file included from ../src/decoder/decoder.h:13:
../../nan/nan.h:590:20: error: no type named 'GCEpilogueCallback' in 'v8::Isolate'
v8::Isolate::GCEpilogueCallback callback
~~~~~~~~~~~~~^
../../nan/nan.h:596:20: error: no type named 'GCEpilogueCallback' in 'v8::Isolate'
v8::Isolate::GCEpilogueCallback callback) {
~~~~~~~~~~~~~^
../../nan/nan.h:601:20: error: no type named 'GCPrologueCallback' in 'v8::Isolate'
v8::Isolate::GCPrologueCallback callback
~~~~~~~~~~~~~^
../../nan/nan.h:607:20: error: no type named 'GCPrologueCallback' in 'v8::Isolate'
v8::Isolate::GCPrologueCallback callback) {
~~~~~~~~~~~~~^
../../nan/nan.h:1927:15: warning: 'SetAccessor' is deprecated [-Wdeprecated-declarations]
return obj->SetAccessor(
^
/Users/and1/.node-gyp/7.0.0/include/node/v8.h:2761:22: note: 'SetAccessor' has been explicitly marked deprecated here
bool SetAccessor(Local<Name> name,
^
3 warnings and 4 errors generated.
make: *** [Release/obj.target/lwip_decoder/src/decoder/init.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:191:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Darwin 16.1.0
gyp ERR! command "/usr/local/Cellar/node/7.0.0/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd node_modules/asciify-image/node_modules/lwip
gyp ERR! node -v v7.0.0
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
./
└── (empty)
npm WARN enoent ENOENT: no such file or directory, open ‘./package.json'
npm ERR! Darwin 16.1.0
npm ERR! argv "/usr/local/Cellar/node/7.0.0/bin/node" "/usr/local/bin/npm" "install" "asciify-image"
npm ERR! node v7.0.0
npm ERR! npm v3.10.8
npm ERR! code ELIFECYCLE
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the lwip package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs lwip
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls lwip
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! npm-debug.log
npm ERR! code 1
When trying to asciify an extra wide image such as this: http://placehold.it/620x140/ff00/00ff using the CLI tool, the image should get resized to fit the terminal, however it doesn't.
My image is 620 pixels wide by 140 pixel high.
My terminal is 125 columns wide by 25 rows high.
My image ends up looking like this:
However, if I set the c-ratio
to 1, it comes out okay:
I'm not really sure why this happens and I'm going to do some more digging to see if I can come up with a solution but I figured I would document it on here.
Because the typescript type is a number, we can't use percentage
-h
option means --help
.
But help message describes that -h
means --height
$ asciify image.jpg -h 200
Usage: asciify [options] [path]
Options:
-c, --color true for color, false for B/W
-r, --c-ratio character width-height ratio
-f, --fit resize rule: box, height, width, original, none
-h, --height height to resize to
-w, --width width to resize to
See the readme for detailed options and defaults
Example:
$ asciify lolwut.png -c false
On importing import asciify from 'asciify-image';
, I get a Type error error saying: TypeError: isWindows is not a function
I noticed that the code for grabbing ascii characters is fairly straightforward. It would be nice to be able to provide our own characters string
It would be great, if it was possible to animate ASCII art with https://github.com/bokub/chalk-animation.
const options = {
color: false
}
asciify(fullPath, options).then(asciified => {
logger.log(chalk.green(asciified));
chalkAnimation.rainbow(asciified);
});
https://github.com/ajay-gandhi/asciify-image/blob/master/index.js#L137
The height line has it's closing paren in the wrong position, which causes the height argument to not be included as intended
return [img.bitmap.width * (opts.height / img.bitmap.height, opts.height)];
Should look like this
return [img.bitmap.width * (opts.height / img.bitmap.height), opts.height];
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.