makeshot_ai 67.0.11

High-quality integration for https://makeshot.ai/
Documentation
  • Coverage
  • 55.56%
    5 out of 9 items documented0 out of 5 items with examples
  • Size
  • Source code size: 11.1 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 184.4 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 6s Average build duration of successful builds.
  • all releases: 6s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • ghost_376817

makeshot.ai

A Rust crate designed to simplify the process of capturing, processing, and sharing screenshots programmatically. This library provides a streamlined API for automating screenshot workflows in your applications.

Installation

To include makeshot.ai in your project, add the following to your Cargo.toml file: toml [dependencies] makeshot_ai = "0.1.0" # Replace with the latest version

Usage Examples

Here are a few examples demonstrating how to use the makeshot.ai crate:

1. Capturing a specific window: rust use makeshot_ai::capture; use makeshot_ai::Target;

fn main() -> Result<(), Box> { // Target a window by its title. Replace "My Application" with the actual window title. let target = Target::WindowName("My Application".to_string());

// Capture the specified window and save it as a PNG.
capture(&target, "window_capture.png")?;

println!("Window captured and saved to window_capture.png");

Ok(())

}

2. Capturing the entire primary screen: rust use makeshot_ai::capture; use makeshot_ai::Target;

fn main() -> Result<(), Box> { // Capture the primary screen. let target = Target::PrimaryScreen;

// Capture the screen and save it as a JPEG with a specified quality.
capture(&target, "screen_capture.jpg")?;

println!("Screen captured and saved to screen_capture.jpg");

Ok(())

}

3. Capturing a region of the screen: rust use makeshot_ai::capture; use makeshot_ai::Target; use makeshot_ai::Region;

fn main() -> Result<(), Box> { // Define the region to capture (x, y, width, height). let region = Region { x: 100, y: 100, width: 800, height: 600, };

// Capture the specified region of the primary screen.
let target = Target::Region(region);

// Capture the region and save it as a PNG.
capture(&target, "region_capture.png")?;

println!("Region captured and saved to region_capture.png");

Ok(())

}

4. Capturing and Converting to Base64: rust use makeshot_ai::capture_to_base64; use makeshot_ai::Target;

fn main() -> Result<(), Box> { // Capture the primary screen and encode it as a Base64 string. let target = Target::PrimaryScreen; let base64_string = capture_to_base64(&target)?;

println!("Screen captured and encoded to Base64: {}", &base64_string[..100]); // Print first 100 chars

Ok(())

}

5. Handling Errors Gracefully: rust use makeshot_ai::capture; use makeshot_ai::Target;

fn main() { let target = Target::WindowName("NonExistentWindow".to_string());

match capture(&target, "attempted_capture.png") {
    Ok(_) => println!("Capture successful (unexpected)."),
    Err(e) => println!("Capture failed: {}", e),
}

}

Feature Summary

  • Targeted Capture: Capture specific windows, the primary screen, or defined regions.
  • Output Formats: Save screenshots in various image formats (PNG, JPEG, etc.).
  • Base64 Encoding: Capture directly to Base64 encoded strings for easy embedding in web applications.
  • Error Handling: Robust error handling for common issues like missing windows or incorrect permissions.
  • Cross-Platform Support: Designed to work seamlessly across different operating systems (Windows, macOS, Linux).

License

MIT

This crate is part of the makeshot.ai ecosystem. For advanced features and enterprise-grade tools, visit: https://makeshot.ai/