Skip to content

Commit

Permalink
Updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
IonicaBizau committed Apr 26, 2016
1 parent 52ddb1b commit 785398c
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 11 deletions.
4 changes: 3 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ Contributions are more than welcome!

Thanks! :sweat_smile:



[1]: https://github.com/IonicaBizau/image-to-ascii/issues

[2]: https://github.com/IonicaBizau/code-style
[2]: https://github.com/IonicaBizau/code-style
63 changes: 63 additions & 0 deletions DOCUMENTATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
## Documentation

You can see below the API reference of this module.

### `imageToAscii(source, options, callback)`
Converts the provided image in ASCII art.

#### Params
- **String** `source`: The path/url to the image.
- **Object|String** `options`: The path to the image or an object containing the following fields:

**Size Options**:
- `pxWidth` (Number): The pixel width used for aspect ratio (default: `2`).
- `size` (Object): The size of the result image (ASCII art)—interpreted by
[`compute-size`](https://github.com/IonicaBizau/compute-size):
- `height` (Number|String): The height value (default: `"100%"`).
- `width` (Number|String): The width value (default: computed value to
keep aspect ratio). This is optional if the height is provided.
- `size_options` (Object): The options for
[`compute-size`](https://github.com/IonicaBizau/compute-size):
- `screen_size` (Object): The screen size (defaults to terminal width
and height):
- `width` (Number): The screen width.
- `height` (Number): The screen height.
- `px_size` (Object): The pixel size.
- `width` (default: `1`)
- `height` (default: `1`)
- `preserve_aspect_ratio` (Boolean): If `false`, the aspect ratio will
not be preserved (default: `true`).
- `fit_screen` (Boolean): If `false`, the result size will not fit to
screen (default: `true`).

**Matrix asciifier options**:
- `stringify` (Boolean): If `false`, the pixel objects will not be
stringified.
- `concat` (Boolean): If `false`, the pixel objects will not be joined
together.

**Pixel asciifier options**:

- `pixels` (Array|String): An array or string containing the characters
used for converting the pixels in strings
(default: `" .,:;i1tfLCG08@"`).
- `reverse` (Boolean): If `true`, the pixels will be reversed creating a
*negative image* effect (default: `false`).
- `colored` (Boolean): If `true`, the output will contain ANSI styles
(default: `true`).
- `bg` (Boolean): If `true`, the **background** color will be used for
coloring (default: false).
- `fg` (Boolean): If `true`, the **foreground** color will be used for
coloring (default: true).
- `white_bg` (Boolean): Turn on the white background for transparent
pixels (default: `true`).
- `px_background` (Object): An object containing the `r` (red), `g`
(green) and `b` (blue) values of the custom background color.

**Other options**:
- `image_type` (String): Use this to explicitely provide the image type.
- `stringify_fn` (Function): A function getting the `pixels` matrix and
the `options` in the arguments. Use this option to implement your own
stringifier.
- **Function** `callback`: The callback function.

24 changes: 14 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

[![image-to-ascii](http://i.imgur.com/pKydY5P.png)](#)

# image-to-ascii [![PayPal](https://img.shields.io/badge/%24-paypal-f39c12.svg)][paypal-donations] [![Version](https://img.shields.io/npm/v/image-to-ascii.svg)](https://www.npmjs.com/package/image-to-ascii) [![Downloads](https://img.shields.io/npm/dt/image-to-ascii.svg)](https://www.npmjs.com/package/image-to-ascii) [![Get help on Codementor](https://cdn.codementor.io/badges/get_help_github.svg)](https://www.codementor.io/johnnyb?utm_source=github&utm_medium=button&utm_term=johnnyb&utm_campaign=github)
Expand All @@ -7,19 +8,19 @@
[![image-to-ascii](http://i.imgur.com/Om8G7dZ.png)](#)

## :cloud: Installation

```sh
$ npm i --save image-to-ascii
```


:bulb: **ProTip**: You can install the [cli version of this module](http://github.com/IonicaBizau/image-to-ascii-cli) by running `npm i -g image-to-ascii-cli`

Check out the [INSTALLTION.md](/INSTALLTION.md) guide for more information.

## :clipboard: Example



```js
// Dependencies
Expand All @@ -37,7 +38,7 @@ imageToAscii("https://octodex.github.com/images/privateinvestocat.jpg", {
console.log(err || converted);
});
```


In order to run the `webcam.sh` provided in the `example` folder, you will also need streamer. The script uses streamer to make webcam pictures and converts them into ASCII art using the `webcam.js`

Expand All @@ -53,7 +54,8 @@ sh webcam.sh
```

## :memo: Documentation


### `imageToAscii(source, options, callback)`
Converts the provided image in ASCII art.

Expand Down Expand Up @@ -113,22 +115,24 @@ Converts the provided image in ASCII art.
stringifier.
- **Function** `callback`: The callback function.



## :yum: How to contribute
Have an idea? Found a bug? See [how to contribute][contributing].

## :dizzy: Where is this library used?
If you are using this library in one of your projects, add it in this list. :sparkles:


- [`alphabet-cli`](https://github.com/joliveros/alphabet-cli#readme)—undefined
- [`ascii-github`](https://npmjs.com/package/ascii-github)—GitHub CLI Client
- [`cli-github`](https://github.com/IonicaBizau/cli-github)—A fancy GitHub client for command line.
- [`cli-sunset`](https://github.com/IonicaBizau/cli-sunset)—A fancy command line tool for knowing the sunset time.
- [`doomjs`](https://github.com/codezilla-it/doom#readme) (by Fabio Cencetti)—A bunch of modular gulp tasks
- [`gif-cli`](https://github.com/IonicaBizau/gif-cli)—Gif animations in your terminal!
- [`ick`](https://github.com/nteract/ick#readme) (by Kyle Kelley)—Interactive Console Experiment
- [`image-to-ascii-cli`](https://github.com/IonicaBizau/image-to-ascii-cli#readme)—View images in text format, in your terminal.
- [`image-to-js`](https://github.com/xinyu198736/image-to-js#readme) (by yutou)—用js代码和图片,生成一段可以正常运行的图形化的js源代码
- [`img-to-svg`](https://github.com/IonicaBizau/img-to-svg#readme)—Convert the image pixels in SVG squares.
- [`imgurize`](https://github.com/mkaminsky11/imgurize) (by Michael Kaminsky)—an Imgur browser in the terminal
- [`joctodex`](https://github.com/IonicaBizau/joctodex#readme)—Octocats in terminal!
- [`js2image`](https://github.com/xinyu198736/image-to-js#readme) (by yutou)—用js代码和图片,生成一段可以正常运行的图形化的js源代码
Expand All @@ -138,9 +142,9 @@ If you are using this library in one of your projects, add it in this list. :spa
- [`tmuxos`](https://github.com/TmuxOS/TmuxOS)—The awesome power of command line is finally revealed.

## :scroll: License

[MIT][license] © [Ionică Bizău][website]

[paypal-donations]: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RVXDDLKKLQRJW
[donate-now]: http://i.imgur.com/6cMbHOC.png

Expand Down

0 comments on commit 785398c

Please sign in to comment.