### Install streamer for webcam example Source: https://github.com/ionicabizau/image-to-ascii/blob/master/README.md Install the streamer utility on Ubuntu or CentOS/RHEL systems, which is required for the webcam.sh script to capture webcam images. ```sh # Ubuntu $ sudo apt-get install streamer # CentOS / RHEL $ sudo yum install --enablerepo epel GraphicsMagick ``` -------------------------------- ### Install image-to-ascii Package Source: https://github.com/ionicabizau/image-to-ascii/blob/master/INSTALLATION.md Install the image-to-ascii npm package using the npm i command. ```sh $ npm i --save image-to-ascii ``` -------------------------------- ### Install GraphicsMagick on Ubuntu Source: https://github.com/ionicabizau/image-to-ascii/blob/master/INSTALLATION.md Use apt-get to install GraphicsMagick on Ubuntu systems. ```sh # Ubuntu $ sudo apt-get install graphicsmagick ``` -------------------------------- ### Install GraphicsMagick on Windows with Chocolatey Source: https://github.com/ionicabizau/image-to-ascii/blob/master/INSTALLATION.md Install GraphicsMagick on Windows using the Chocolatey package manager. A restart of cmd/PowerShell is required after installation. ```sh # Chocolatey (package manager for Windows) # (Restart of cmd/PowerShell is required) $ choco install graphicsmagick ``` -------------------------------- ### Install GraphicsMagick on Fedora Source: https://github.com/ionicabizau/image-to-ascii/blob/master/INSTALLATION.md Use dnf to install GraphicsMagick on Fedora systems. ```sh # Fedora $ sudo dnf install GraphicsMagick ``` -------------------------------- ### Install image-to-ascii with npm or yarn Source: https://github.com/ionicabizau/image-to-ascii/blob/master/README.md Use npm or yarn to add the image-to-ascii module to your project dependencies. ```sh # Using npm npm install --save image-to-ascii # Using yarn yarn add image-to-ascii ``` -------------------------------- ### Install GraphicsMagick on OS X Source: https://github.com/ionicabizau/image-to-ascii/blob/master/INSTALLATION.md Use Homebrew to install GraphicsMagick on OS X. ```sh # OS X $ brew install graphicsmagick ``` -------------------------------- ### Install GraphicsMagick on CentOS/RHEL Source: https://github.com/ionicabizau/image-to-ascii/blob/master/INSTALLATION.md Use yum to install GraphicsMagick on CentOS/RHEL systems, enabling the epel repository. ```sh # CentOS / RHEL $ sudo yum install --enablerepo epel GraphicsMagick ``` -------------------------------- ### Run webcam.sh script Source: https://github.com/ionicabizau/image-to-ascii/blob/master/README.md Execute the webcam.sh script to capture images from a webcam and convert them into ASCII art. ```sh sh webcam.sh ``` -------------------------------- ### ASCII Art with Screen Size Hint for Scaling Source: https://context7.com/ionicabizau/image-to-ascii/llms.txt Provides a screen size hint to the library for correct scaling, especially in non-TTY contexts. Preserves aspect ratio and fits the screen. ```javascript // 8. Screen-size hint so the library scales correctly in a non-TTY context imageToAscii("/path/to/image.png", { size_options: { screen_size: { width: 220, height: 50 }, preserve_aspect_ratio: true, fit_screen: true } }, (err, converted) => { if (err) { return console.error(err); } process.stdout.write(converted + "\n"); }); ``` -------------------------------- ### Add Contributor to package.json Source: https://github.com/ionicabizau/image-to-ascii/blob/master/CONTRIBUTING.md When contributing to this project, if a package.json or bower.json file exists, add yourself to the 'contributors' array. Create the array if it does not exist. ```json { "contributors": [ "Your Name (http://your.website)" ] } ``` -------------------------------- ### imageToAscii(source, options, callback) Source: https://github.com/ionicabizau/image-to-ascii/blob/master/DOCUMENTATION.md Converts the provided image into ASCII art. It accepts various options to customize the output, including size, character mapping, and colorization. ```APIDOC ## `imageToAscii(source, options, callback)` ### Description Converts the provided image in ASCII art. ### Parameters - **`source`** (String|Buffer): The path/url to the image or a Buffer object. - **`options`** (Object|String): The path to the image or an object containing various configuration fields. - **Size Options**: - `pxWidth` (Number): The pixel width used for aspect ratio (default: `2`). - `size` (Object): The size of the result image (ASCII art). - `height` (Number|String): The height value (default: `"100%"`). - `width` (Number|String): The width value (optional if height is provided). - `size_options` (Object): Options for `compute-size`. - `screen_size` (Object): The screen size. - `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 (default: `true`). - `concat` (Boolean): If `false`, the pixel objects will not be joined together (default: `true`). - **Pixel asciifier options**: - `pixels` (Array|String): Characters used for converting pixels (default: `" .,:;i1tfLCG08@"`). - `reverse` (Boolean): If `true`, reverses pixels for a negative image effect (default: `false`). - `colored` (Boolean): If `true`, output contains ANSI styles (default: `true`). - `bg` (Boolean): If `true`, uses background color for coloring (default: `false`). - `fg` (Boolean): If `true`, uses foreground color for coloring (default: `true`). - `white_bg` (Boolean): Enables white background for transparent pixels (default: `true`). - `px_background` (Object): Custom background color (r, g, b values). - **Other options**: - `image_type` (String): Explicitly provide the image type. - `stringify_fn` (Function): Custom stringifier function. - **`callback`** (Function): The callback function. ``` -------------------------------- ### Convert Remote Image to ASCII Art (Colored) Source: https://context7.com/ionicabizau/image-to-ascii/llms.txt Simplest usage for converting a remote image. Produces multi-line ANSI-colored ASCII art. ```javascript const imageToAscii = require("image-to-ascii"); // 1. Simplest usage — convert a remote image with defaults (colored, fits terminal) imageToAscii("https://octodex.github.com/images/jetpacktocat.png", (err, converted) => { if (err) { return console.error("Conversion failed:", err); } console.log(converted); // Output: multi-line ANSI-colored ASCII art printed to stdout }); ``` -------------------------------- ### Convert Local Image File to ASCII Art Source: https://context7.com/ionicabizau/image-to-ascii/llms.txt Converts an image from a local file path to ASCII art. Ensure the path is correct. ```javascript // 2. Local file path imageToAscii("/path/to/photo.jpg", (err, converted) => { if (err) { return console.error(err); } console.log(converted); }); ``` -------------------------------- ### Convert Webcam Snapshot to ASCII Art Source: https://context7.com/ionicabizau/image-to-ascii/llms.txt Converts a local JPEG file, such as a webcam snapshot, to ASCII art with background color mode enabled. ```javascript // 10. Convert a webcam snapshot (local JPEG file captured externally) imageToAscii(`${__dirname}/webcam-out.jpeg`, { bg: true }, (err, converted) => { if (err) { return console.error(err); } console.log(converted); }); ``` -------------------------------- ### Inspect and Modify image-to-ascii Defaults Source: https://context7.com/ionicabizau/image-to-ascii/llms.txt Access and mutate the `imageToAscii.defaults` object to change fallback values globally. This can be used to set default options like `colored` or provide a custom `stringify_fn` for all subsequent calls. ```javascript const imageToAscii = require("image-to-ascii"); // Inspect built-in defaults console.log(imageToAscii.defaults); // { // size_options: { px_size: { width: } }, // stringify: true, // concat: true, // size: { height: "100%" }, // stringify_fn: [Function: asciifyPixelMatrix] // } // Override defaults globally — all future calls will use colored: false imageToAscii.defaults.colored = false; // Provide a completely custom stringify function globally imageToAscii.defaults.stringify_fn = (pixels, options) => { return pixels .map(row => row.map(px => (px.r + px.g + px.b > 382 ? "░" : "█")).join("")) .join("\n"); }; imageToAscii("https://octodex.github.com/images/jetpacktocat.png", (err, result) => { console.log(result); // Output: image rendered using only "░" and "█" block characters }); ``` -------------------------------- ### Access Raw Pixel Matrix for Custom Rendering Source: https://context7.com/ionicabizau/image-to-ascii/llms.txt Receives the raw pixel matrix instead of a string by setting `stringify: false`. Allows manual manipulation of pixels before rendering, such as overlaying custom text. ```javascript const stringify = require("asciify-pixel-matrix"); imageToAscii("https://octodex.github.com/images/baracktocat.jpg", { bg: true, fg: false, stringify: false, // receive the pixel matrix instead of a string concat: false }, (err, converted) => { if (err) { return console.error(err); } // Overlay repeating text onto the image colors const snip = "Yes we code! "; let i = 0; converted.forEach(row => { row.forEach(px => { px.char = snip[i = ++i % snip.length]; }); }); console.log(stringify.stringifyMatrix(converted)); // Output: image rendered with custom repeating text characters instead of brightness chars }); ``` -------------------------------- ### Convert Image to ASCII Art Source: https://github.com/ionicabizau/image-to-ascii/blob/master/README.md Convert an image from a URL to ASCII art. Handles errors and provides the converted string. Optionally pass options to customize the conversion. ```javascript // Dependencies const imageToAscii = require("image-to-ascii"); // The path can be either a local path or an url imageToAscii("https://octodex.github.com/images/octofez.png", (err, converted) => { console.log(err || converted); }); // Passing options imageToAscii("https://octodex.github.com/images/privateinvestocat.jpg", { colored: false }, (err, converted) => { console.log(err || converted); }); ``` -------------------------------- ### Convert Image with Custom Palette and Negative Effect Source: https://context7.com/ionicabizau/image-to-ascii/llms.txt Uses a custom character palette for ASCII conversion and applies a negative (inverted brightness) effect. Output is plain text. ```javascript // 6. Custom character palette and negative (reversed) image effect imageToAscii("/path/to/portrait.png", { pixels: "@#S%?*+;:,. ", // darkest → lightest reverse: true, // invert brightness mapping for negative effect colored: false }, (err, converted) => { if (err) { return console.error(err); } console.log(converted); }); ``` -------------------------------- ### Convert Image to Fixed Size ASCII Art Source: https://context7.com/ionicabizau/image-to-ascii/llms.txt Converts an image to a fixed output size (width and height), aspect ratio may not be preserved. ```javascript // 5. Fixed output size (80 columns × 40 rows), aspect ratio not preserved imageToAscii("https://octodex.github.com/images/octofez.png", { size: { width: 80, height: 40 }, size_options: { preserve_aspect_ratio: false } }, (err, converted) => { if (err) { return console.error(err); } console.log(converted); }); ``` -------------------------------- ### Convert Image with Custom Transparent Pixel Background Source: https://context7.com/ionicabizau/image-to-ascii/llms.txt Sets a custom background color for transparent pixels, useful for terminals with dark backgrounds. ```javascript // 7. Custom background color for transparent pixels (e.g. dark terminal) imageToAscii("https://octodex.github.com/images/octofez.png", { white_bg: false, px_background: { r: 0, g: 0, b: 0 } // black background }, (err, converted) => { if (err) { return console.error(err); } console.log(converted); }); ``` -------------------------------- ### Convert Image to Background Color ASCII Art Source: https://context7.com/ionicabizau/image-to-ascii/llms.txt Renders ASCII art where color is applied to the background of each character cell, useful for specific terminal themes. ```javascript // 4. Background color mode instead of foreground color imageToAscii("https://octodex.github.com/images/octofez.png", { bg: true, fg: false }, (err, converted) => { if (err) { return console.error(err); } console.log(converted); // Output: ASCII art where color is applied to the background of each character cell }); ``` -------------------------------- ### Convert Image to Plain Text ASCII Art Source: https://context7.com/ionicabizau/image-to-ascii/llms.txt Converts an image to ASCII art without ANSI escape codes for plain text output. ```javascript // 3. Non-colored (plain text) output imageToAscii("https://octodex.github.com/images/privateinvestocat.jpg", { colored: false }, (err, converted) => { if (err) { return console.error(err); } console.log(converted); // Output: plain ASCII art without any ANSI escape codes }); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.