43 releases

0.8.10 Mar 1, 2024
0.8.8 Feb 1, 2024
0.8.6 Dec 16, 2023
0.8.5 Nov 1, 2023
0.0.3 Mar 29, 2022

#181 in Images

Download history 758/week @ 2024-07-19 615/week @ 2024-07-26 2077/week @ 2024-08-02 1065/week @ 2024-08-09 403/week @ 2024-08-16 358/week @ 2024-08-23 613/week @ 2024-08-30 484/week @ 2024-09-06 510/week @ 2024-09-13 839/week @ 2024-09-20 1024/week @ 2024-09-27 1523/week @ 2024-10-04 523/week @ 2024-10-11 601/week @ 2024-10-18 567/week @ 2024-10-25 809/week @ 2024-11-01

2,708 downloads per month
Used in fewer than 12 crates

Apache-2.0

31KB
743 lines

πŸ“· Screenshots

Move to XCap

Screenshots is a cross-platform screenshots library for MacOS, Windows, Linux (X11, Wayland) written in Rust. It provides a simple API for capturing screenshots of a screen or a specific area of a screen.

Example

The following example shows how to capture screenshots of all screens and a specific area of a screen.

use screenshots::Screen;
use std::time::Instant;

fn main() {
    let start = Instant::now();
    let screens = Screen::all().unwrap();

    for screen in screens {
        println!("capturer {screen:?}");
        let mut image = screen.capture().unwrap();
        image
            .save(format!("target/{}.png", screen.display_info.id))
            .unwrap();

        image = screen.capture_area(300, 300, 300, 300).unwrap();
        image
            .save(format!("target/{}-2.png", screen.display_info.id))
            .unwrap();
    }

    let screen = Screen::from_point(100, 100).unwrap();
    println!("capturer {screen:?}");

    let image = screen.capture_area(300, 300, 300, 300).unwrap();
    image.save("target/capture_display_with_point.png").unwrap();
    println!("θΏθ‘Œθ€—ζ—Ά: {:?}", start.elapsed());
}

Linux Requirements

On Linux, you need to install libxcb, libxrandr, and dbus.

Debian/Ubuntu:

apt-get install libxcb1 libxrandr2 libdbus-1-3

Alpine:

apk add libxcb libxrandr dbus

ArchLinux:

pacman -S libxcb libxrandr dbus

License

This project is licensed under the Apache License. See the LICENSE file for details.

Dependencies

~5–45MB
~628K SLoC