Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use more colors converting from image? #11

Open
heruan opened this issue Jul 27, 2018 · 3 comments

Comments

@heruan
Copy link

commented Jul 27, 2018

It is not clear how to use more colors when converting an image to ASCII art. For example, this:

$ ascii-art image file.png

and this:

var art = require('ascii-art');

var image = new art.Image({
	filepath: 'file.png'
});
image.write(function(err, rendered){
	console.log(rendered);
})

produce ASCII art with few colors.

@khrome

This comment has been minimized.

Copy link
Owner

commented Jul 27, 2018

@heruan

This comment has been minimized.

Copy link
Author

commented Aug 3, 2018

Thank you for the response! There's no hurry, I'll try the 256 color support when it'll be ready 🙂

@khrome

This comment has been minimized.

Copy link
Owner

commented Sep 2, 2019

The rebuild of ascii-art is almost ready, but If you'd like to try 256 color support early, use ascii-art-image, ascii-art-ansi like so (I'm using ES5 syntax):

var Color = require('ascii-art-ansi/color');
var Image = require('ascii-art-image');
Color.is256 = true; //also supports .isTrueColor if your terminal does
Color.useDistance('closestByIntensity');
var image = new Image({
    width : 80,
    filepath : '/Your/File/Path/To/Image.type',
    alphabet : 'blocks'
});
image.write(function(err, image){
   //image is ready
})

Possible alphabets: variant1, variant2, variant3, variant4, ultra-wide, wide, hatching, bits, binary, greyscale, blocks, solid

Color.useDistance(name); values are : euclideanDistance, classic, ratioDistance, classicByValue, CIE76Difference, closestByIntensity, rankedChannel, simple, original

On release these options will be built into the call options rather than using the static defaults. Let me know if you encounter any issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.