79708779

Date: 2025-07-21 08:37:46
Score: 0.5
Natty:
Report link

Another Go library that would be used: https://github.com/kbinani/screenshot

Install:

go get github.com/kbinani/screenshot

Example:

 package main

 import (
    "github.com/kbinani/screenshot"
    "image/png"
    "os"
    "fmt"
 )

 func main() {
    n := screenshot.NumActiveDisplays()

    for i := 0; i < n; i++ {
        bounds := screenshot.GetDisplayBounds(i)

        img, err := screenshot.CaptureRect(bounds)
        if err != nil {
            panic(err)
        }
        fileName := fmt.Sprintf("%d_%dx%d.png", i, bounds.Dx(), bounds.Dy())
        file, _ := os.Create(fileName)
        defer file.Close()
        png.Encode(file, img)

        fmt.Printf("#%d : %v \"%s\"\n", i, bounds, fileName)
    }
 }
Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Miguel A. C.