1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
use TextImage;
use ;
use CharacterSet;
/// Converts an image to a TextImage using the given character set
///
/// `target_width` is a goal width - the actual width will be a value close to
/// `target_width` that preserves the image's aspect ratio.
///
/// # Example
/// ```
/// # extern crate image;
/// # extern crate txtpic_lib;
/// # fn main() {
/// # use self::image::open;
/// # use std::path::Path;
/// # use txtpic_lib::character_set::CharacterSet;
/// # use txtpic_lib::text_image::image_to_text::image_to_text;
/// // import necessary crates and modules...
///
/// let img = open(Path::new("./example/cat.jpg")).unwrap();
/// let char_set = CharacterSet::preset_small();
/// let txt_img = image_to_text(img, char_set, 80);
/// let cute_kitty = "\
/// ==xxxxxxx=======+++--++-+-.:--:--+:.-+---++++=xxxxxx=====xxxxxx==========++
/// =xxxxxxx====xx=x=++=++++++.++-:--=+--++++++++=====xxx=++=xxxxxx============
/// =xxxx=====xxxxxx+++++++=+--+x+:-=x+-+==+++=+===++=++++--+-+=xx====x========
/// =====x+++xxxx=+++++=++++=+:-x+:-xx-:=x=+-+========+++++---+================
/// +++++++--++++++=====++--=x=-=+-+=x--xxx+-+xxx======+++++---+===========++++
/// --+-++---+++++======x=-:=xx-+=--+x-+xxx-:+x=+=======++++=+++=xx============
/// +--+++---+++++x==+++=x+.-xx=-=--+=-+=xx=-=x=====xx=+++++==+===xxxxx========
/// --++-++++++===xxx===+=x--xxx+++--+=++xxx+=+-+xxx-++--++++++++=xxxxxxxxxxxxx
/// +++-+++=x=====x=++==++==+x=++++++++=+=xxxxx+-xxx++x=+=+++-+===xxxxxxxxxxxxx
/// ++--+=++x====++=+xxx++xxx=xx+==++++==x%++xxxxxx+-x=++++=x=-++xxxxxxxxxxxxxx
/// +++-++++++=xxxxx=+xxxxxx=:=x==+++++==xx+::-----+++--+===xxxx=xx%%%%%%%%%%%%
/// +++--=+++xx===+=xx+++++---+=+=========+-++=++-----++==xxxxx+=xxxxxxxxxxxxxx
/// ++---+===xxx==+++-++++===+-:-=xxx=xx==+:.--::---++==xx+--+++xxxxxxxxxxxxxxx
/// +++++++=xxxxxx=+=++-------::+==xx====+++---++++++xxxxxx=x=xxxxxxx%%%%%%%%%%
/// +----++++++++=xxxx=++++++-----+=====+--++-++=+==xxxxx=+=xxx%%%%%%%%%%%%xxxx
/// +==+--=++++=====xxxxx===+++=--+===+=++--===+===xxxxx==xxxxxxxxx%%%%%%%%%%%%
/// ++=+++++==++====xxxxxxx=+xxx=-==+++++=+=xx=x=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
/// -+++++++++========xxxxxx=x=xxxx=+x==-=xxxx===xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
/// +-+++--+++====xx=xxxxxxxxxxxxxxxx=-+xxxxxxxxxxxxxxxxxx========xxxxxxxxxxxxx
/// ++--++++++++=x=x====xxxxxxxxxxxxxx+=xxxxxxxxxxxxxxxxx=++++++-+=xxxxxxxxxxxx
/// ===+---+=+++++++=xxxxxxxxxxxxxxxxx==xxxxxxxxxxxxxxxxx==+++--+=====+xxxxxxxx
/// +++++-----+++++==++==xx=++++=xxxxxxxxx%xxxxxxxxxxxxx=+++++--+=x=x===xxxxxxx
/// ++++++------++=+-+=+=++++-+-+-++=xxxxxxxxxxxxxxxxxx+++----+++==xxx==xxxxxxx
/// ++==++++--+--+--++++++++++++++++========+==+=xxxxxx=++-::--+==xxxxxxxxxxxxx
/// ";
/// assert_eq!(txt_img.to_string(), cute_kitty);
/// # }
/// ```
// Calculates the interval closest to target_interval such that img_size % target_interval == 0