Compare commits

...

7 Commits

Author SHA1 Message Date
Waveplate
d75b156abc dont bother with luma effects unless braille 2025-05-19 04:54:20 -07:00
Waveplate
a935454124 font install instructions 2025-05-19 00:59:38 -07:00
Waveplate
094b438160 use ansi+block by default 2025-05-19 00:44:33 -07:00
Waveplate
6485c7669a update img2irc banner 2025-05-18 17:14:41 -07:00
Waveplate
5ffa8ef776 add another example img 2025-05-18 01:07:12 -07:00
Waveplate
b68ff08cb9 add second output example 2025-05-18 00:55:06 -07:00
Waveplate
bcf5060b7c fix readme 2025-05-17 11:41:26 -07:00
3 changed files with 53 additions and 29 deletions

View File

@ -2,10 +2,10 @@
*img2irc* is a premiere command-line utility which converts images to irc/ansi art, with a lot of post-processing filters *img2irc* is a premiere command-line utility which converts images to irc/ansi art, with a lot of post-processing filters
`$ img2irc https://i.imgur.com/WWSl2Sb.png --render ansi --blocks --width 132 --contrast 50 --nograyscale` `$ img2irc https://i.imgur.com/qP1uBCK.png`
>   >  
>![img2irc block example](https://i.imgur.com/B9syzEm.png) >![img2irc block example](https://i.imgur.com/ew513lc.png)
>   >  
# how to install # how to install
@ -31,6 +31,30 @@
> [!NOTE] > [!NOTE]
> if you like this project, i would appreciate you giving it a vote on the [aur](https://aur.archlinux.org/packages/img2irc-bin)! > if you like this project, i would appreciate you giving it a vote on the [aur](https://aur.archlinux.org/packages/img2irc-bin)!
# font installation (recommended)
certain glyph types (triangle, corner, geometric, box, legacy) require google's noto fonts extras to render correctly. full, half, quarter and eighth blocks typically work without extra fonts.
## debian/ubuntu
```bash
sudo apt update
sudo apt install fonts-noto
```
## arch linux
```bash
sudo pacman -S noto-fonts noto-fonts-extra
```
## windows
1. download the latest noto-fonts zip from https://github.com/googlefonts/noto-fonts/releases/latest
2. extract the archive
3. install the .ttf files you need (e.g., noto sans symbols, noto sans symbols 2) by right-clicking → install, or copy them to c:\windows\fonts
# usage # usage
`img2irc <URL or PATH> [OPTIONS]` `img2irc <URL or PATH> [OPTIONS]`
@ -49,9 +73,9 @@
### colours rendering modes ### colours rendering modes
| option | description | | option | description | default |
|----------------------------------------|---------------------------------------------------------------| |----------------------------------------|-----------------------------|------------------|
| --render | colour rendering mode (default: `irc`) | | --render | colour rendering mode | `ansi` |
`irc` mode has 99 colours, (6.62-bit) `irc` mode has 99 colours, (6.62-bit)
@ -59,22 +83,22 @@
`ansi24` has 16777216 colours (24-bit) `ansi24` has 16777216 colours (24-bit)
### pixel rendering modes (select one) ### pixel rendering modes
| option | description | | option | description | default |
|---------------|-------------------------------| |---------------|-------------------------------|--------------|
| `--braille` | use braille pixels | | `--braille` | use braille pixels | `false` |
| `--blocks[=types]` | use block pixels of the provided types. defaults to `full,half,quarter,eighth,triangle,corner,geometric,box,legacy` | | `--blocks[=types]` | use block pixels of the provided types | `full,half,quarter,eighth,triangle,corner,geometric,box,legacy` |
#### braille mode #### braille mode
`--braille` uses 2×4 braille dot patterns, doubling horizontal and octupling vertical resolution `--braille` uses 2×4 braille dot patterns, doubling horizontal and quadrupling vertical resolution
#### block modes #### block modes
| type | description | unicode range | | type | description | unicode range |
|-----------|----------------------|----------------| |-----------|----------------------|----------------|
| `full` | full block | 0x2588 | | `full` | full block | 0x20 + 0x2588 |
| `half` | half block | 0x2580-0x2590 | | `half` | half block | 0x2580-0x2590 |
| `quarter` | quarter block | 0x2596-0x259F | | `quarter` | quarter block | 0x2596-0x259F |
| `eighth` | eighth block | 0x2581-0x2595 | | `eighth` | eighth block | 0x2581-0x2595 |
@ -86,7 +110,7 @@
specifying `--blocks` with no value uses all available glyph types specifying `--blocks` with no value uses all available glyph types
`full` only uses the fullblock glyph `full` only uses the ASCII space and fullblock glyph
`half` increases the vertical resolution twofold `half` increases the vertical resolution twofold
@ -102,6 +126,8 @@ specifying `--blocks` with no value uses all available glyph types
`box` uses some box-drawing characters `box` uses some box-drawing characters
`legacy` uses some legacy geometric shapes
> see `src/chars.rs` for the actual glyphs and bitmaps or read `utils/README.md` for information on how to generate a custom `chars.rs` file > see `src/chars.rs` for the actual glyphs and bitmaps or read `utils/README.md` for information on how to generate a custom `chars.rs` file
### image processing options ### image processing options
@ -149,3 +175,5 @@ specifying `--blocks` with no value uses all available glyph types
| --frostedglass | blurred, frosted appearance as if viewed through semi-transparent surface | false | | --frostedglass | blurred, frosted appearance as if viewed through semi-transparent surface | false |
| --solarize | strange, otherworldly appearance with inverted colors and surreal atmosphere | false | | --solarize | strange, otherworldly appearance with inverted colors and surreal atmosphere | false |
| --edgedetection | highlights edges and boundaries in an image | false | | --edgedetection | highlights edges and boundaries in an image | false |
![img2irc example 2](https://i.imgur.com/BWs5Hfd.png)

View File

@ -77,7 +77,7 @@ pub struct Args {
pub flipv: bool, pub flipv: bool,
/// colour mode to use /// colour mode to use
#[arg(long, value_enum, default_value_t = Render::Irc)] #[arg(long, value_enum, default_value_t = Render::Ansi)]
pub render: Render, pub render: Render,
/// use braille pixels /// use braille pixels
@ -85,7 +85,6 @@ pub struct Args {
long, long,
default_value_t = false, default_value_t = false,
conflicts_with = "block", conflicts_with = "block",
required_unless_present = "blocks"
)] )]
pub braille: bool, pub braille: bool,
@ -95,7 +94,7 @@ pub struct Args {
value_enum, value_enum,
value_delimiter = ',', value_delimiter = ',',
num_args = 0.., num_args = 0..,
default_missing_values = &[ default_values = &[
"full", "full",
"half", "half",
"quarter", "quarter",
@ -107,7 +106,6 @@ pub struct Args {
"legacy", "legacy",
], ],
conflicts_with = "braille", conflicts_with = "braille",
required_unless_present = "braille"
)] )]
pub blocks: Vec<BlockKind>, pub blocks: Vec<BlockKind>,

View File

@ -15,25 +15,23 @@ async fn main() {
match load_image_from_url_or_path(args.image.as_str()).await { match load_image_from_url_or_path(args.image.as_str()).await {
Ok(image) => { Ok(image) => {
let image_luma = effects::apply_luma_effects(&args, image.clone());
let image_chroma = effects::apply_effects(&args, image.clone());
let canvas_luma = draw::AnsiImage::new(image_luma.clone()); let image = effects::apply_effects(&args, image.clone());
let canvas_chroma = draw::AnsiImage::new(image_chroma.clone()); let canvas = draw::AnsiImage::new(image.clone());
if args.braille { if args.braille {
// Braille rendering let image_luma = effects::apply_luma_effects(&args, image.clone());
let canvas_luma = draw::AnsiImage::new(image_luma.clone());
match args.render { match args.render {
args::Render::Irc => println!("{}", draw::render_braille(&canvas_luma, &canvas_chroma, &args, args::Render::Irc)), args::Render::Irc => println!("{}", draw::render_braille(&canvas_luma, &canvas, &args, args::Render::Irc)),
args::Render::Ansi => println!("{}", draw::render_braille(&canvas_luma, &canvas_chroma, &args, args::Render::Ansi)), args::Render::Ansi => println!("{}", draw::render_braille(&canvas_luma, &canvas, &args, args::Render::Ansi)),
args::Render::Ansi24 => println!("{}", draw::render_braille(&canvas_luma, &canvas_chroma, &args, args::Render::Ansi24)), args::Render::Ansi24 => println!("{}", draw::render_braille(&canvas_luma, &canvas, &args, args::Render::Ansi24)),
} }
} else { } else {
// Block rendering
match args.render { match args.render {
args::Render::Irc => println!("{}", draw::render_blocks(&canvas_chroma, &args, args::Render::Irc)), args::Render::Irc => println!("{}", draw::render_blocks(&canvas, &args, args::Render::Irc)),
args::Render::Ansi => println!("{}", draw::render_blocks(&canvas_chroma, &args, args::Render::Ansi)), args::Render::Ansi => println!("{}", draw::render_blocks(&canvas, &args, args::Render::Ansi)),
args::Render::Ansi24 => println!("{}", draw::render_blocks(&canvas_chroma, &args, args::Render::Ansi24)), args::Render::Ansi24 => println!("{}", draw::render_blocks(&canvas, &args, args::Render::Ansi24)),
} }
} }
} }