tapciify/lib.rs
1//! > **Tool to convert your images into ASCII art**
2//!
3//! Useful functions, when using as lib
4//! - [`AsciiArtConverter::ascii_art`]
5//! - [`CustomRatioResize::resize_custom_ratio`]
6//!
7//! ## Installation
8//!
9//! ```bash
10//! cargo install tapciify
11//! ```
12//!
13//! ## Converting image
14//!
15//! 1. Run: `tapciify -i imagePath -w imageWidth` for image.
16//!
17//! 2. Run: `tapciify -i imagePath -w imageWidth -r` for reversed colors.
18//!
19//! ## Converting video
20//!
21//! In this example I set framerate to 24 (but you can use any another)
22//!
23//! > Requires ffmpeg
24//!
25//! 1. Make frames from video into dir:
26//!
27//! ```bash
28//! mkdir frames; ffmpeg -i bad_apple.mkv frames/%08d.jpeg
29//! ```
30//!
31//! 2. Run:
32//!
33//! ```bash
34//! tapciify -i frames/* -w videoWidth -f 24
35//! ```
36//!
37//! # Examples
38//!
39//! Demo:
40//!
41//! ```
42//! use image::imageops::FilterType;
43//!
44//! # use std::error::Error;
45//!
46//! use tapciify::{
47//! AsciiArtConverter, AsciiArtConverterOptions, CustomRatioResize, DEFAULT_FONT_RATIO,
48//! };
49//!
50//! # fn main() -> Result<(), Box<dyn Error>> {
51//! let img = image::open("./assets/examples/ferris.webp")?;
52//!
53//! let result = img
54//! .resize_custom_ratio(Some(64), None, DEFAULT_FONT_RATIO, FilterType::Triangle)
55//! .ascii_art(&AsciiArtConverterOptions {
56//! // Put your other options here
57//! ..Default::default()
58//! })?;
59//!
60//! println!("{}", result);
61//! # Ok(())
62//! # }
63//! ```
64//!
65//! Colored:
66//!
67//! ```
68//! use std::error::Error;
69//!
70//! # use image::imageops::FilterType;
71//!
72//! use tapciify::{
73//! AsciiArtConverter, AsciiArtConverterOptions, CustomRatioResize, DEFAULT_FONT_RATIO,
74//! };
75//!
76//! # fn main() -> Result<(), Box<dyn Error>> {
77//! let img = image::open("./assets/examples/ferris.webp")?;
78//!
79//! let result = img
80//! .resize_custom_ratio(Some(64), None, DEFAULT_FONT_RATIO, FilterType::Triangle)
81//! .ascii_art(&AsciiArtConverterOptions {
82//! // Put your other options here
83//! colored: true,
84//! ..Default::default()
85//! })?;
86//!
87//! println!("{}", result);
88//! # Ok(())
89//! # }
90//! ```
91
92#[allow(deprecated)]
93#[doc(inline)]
94pub use ascii::{
95 ascii_character, AsciiArt, AsciiArtConverter, AsciiArtConverterError, AsciiArtConverterOptions,
96 AsciiArtPixel, AsciiStringError, ReverseString, SizeError, ToAsciiArtPixel,
97 DEFAULT_ASCII_STRING,
98};
99#[doc(inline)]
100#[cfg(feature = "player")]
101pub use player::{AsciiPlayer, AsciiPlayerError, AsciiPlayerOptions};
102#[doc(inline)]
103pub use resize::{CustomRatioResize, DEFAULT_FONT_RATIO};
104
105pub mod ascii;
106pub mod macros;
107pub mod resize;
108
109#[cfg(feature = "player")]
110pub mod player;
111
112#[cfg(feature = "braille")]
113pub mod braille;
114
115#[cfg(feature = "background-string")]
116pub mod background_string;
117
118#[cfg(feature = "threshold-utils")]
119pub mod threshold_utils;
120
121#[cfg(feature = "player")]
122pub mod cli;