IonicaBizau / image-to-ascii

:floppy_disk: A Node.js module that converts images to ASCII art.
http://ionicabizau.net/blog/16
MIT License
1.58k stars 106 forks source link

Image width on scale #31

Closed phoenixbox closed 8 years ago

phoenixbox commented 8 years ago

Hi there,

so I am trying to convert a 100px x 100px png to ascii. When I do so with the following options:

const options = {
   concat: false,
   colored: false
}
imageToAscii(image, options, (err, converted) => {
      if (err) {
        next(err, null)
      } else {
        console.log('ROWS', converted.length);
        console.log('COLS', converted[0].length);
        next(null, converted)
      }
});

I get an ascii output with the following number of rows and columns:

ROWS 60
COLS 120

I was expecting to get an output with an equal number of rows and cols (100 rows && 100 cols), thus keeping the aspect ratio. I have also been trying many variations of the options parameters, hoping to get the correctly scaled output.

Could you tell me where I am going wrong / suggest the correct options params to keep my image at the right aspect ratio?

Thanks!

image

IonicaBizau commented 8 years ago

That's the default behavior: 100% height and computed width.

If you want 100px size you need to explicitly provide the size:

options.size = { height: 100 };

The width will be computed.