Skip to main content

edit_image/
edit_image.rs

1//! Image editing example - modifies an existing image with a text prompt.
2//!
3//! Run with: `cargo run --example edit_image -- <input_image.png>`
4//!
5//! Requires `GOOGLE_API_KEY` environment variable.
6
7use genviz::{GeminiProvider, GenerationRequest, ImageProvider};
8
9#[tokio::main]
10async fn main() -> genviz::Result<()> {
11    let input_path = std::env::args()
12        .nth(1)
13        .expect("Usage: edit_image <input_image.png>");
14
15    let input_bytes = std::fs::read(&input_path)?;
16
17    let provider = GeminiProvider::builder().build()?;
18
19    let request = GenerationRequest::new("Make the colors more vibrant and add a warm sunset glow")
20        .with_input_image(input_bytes);
21
22    let image = provider.generate(&request).await?;
23    image.save("edited.png")?;
24    println!("Edited image saved to edited.png ({} bytes)", image.size());
25
26    Ok(())
27}