Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fine-tune display_image() in main.rs #29

Merged
merged 2 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# tnap - Let's take a nap 💤

## What's `tnap`?

`tnap` is the screen save for TUI.
You can use sample themes for tnap and generate image with default prompts or your own prompts.

## Examples

### Prompt
Expand All @@ -17,19 +22,21 @@
## Usage

```
Generate image with DALL-E and print it
You can use sample themes for tnap and generate image with default prompts or your own prompts

Usage: tnap [OPTIONS]

Options:
-p, --prompt <PROMPT> Prompt to pass to DALL-E
-t, --theme <THEME> Use the sample theme without generating images
-k, --key <KEY> Generate Image by looking up the corresponding value in config.toml using the subsequent string as a key and using it as a prompt
-p, --prompt <PROMPT> Generate images with user-considered prompt
-a, --ascii Convert an image to ASCII art
-h, --help Print help
-V, --version Print version
```

```sh
$ cargo run
cargo run
```

## License
Expand Down
7 changes: 6 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use anyhow::Result;
use clap::Parser;
use convert_image_to_ascii::convert_image_to_ascii;
use dotenv::dotenv;
use generate_image::{download_image, generate_image};
use std::fs;
Expand Down Expand Up @@ -85,7 +86,11 @@ fn display_generated_image_from_prompt(prompt: &str, ascii: bool) -> Result<()>

fn display_image(path: &str, ascii: bool) -> Result<()> {
if ascii {
convert_image_to_ascii(&path)?;
let ascii_art = convert_image_to_ascii(Path::new(&path));
match ascii_art {
Ok(art) => println!("{}", art), // 成功した場合、ASCII アートを出力
Err(e) => println!("Error converting image to ASCII: {:?}", e), // エラーが発生した場合、エラーメッセージを出力
}
} else {
println!("Displaying image: {}", path);
// render_image(&path)?;
Expand Down