Screenshot Save

Go library to capture desktop to image

Project README

screenshot

Go Report Card

  • Go library to capture desktop screen.
  • Multiple display supported.
  • Supported GOOS: windows, darwin, linux, freebsd, openbsd, and netbsd.
  • cgo free except for GOOS=darwin.

example

  • sample program main.go

    ackage main
    
    mport (
    "github.com/kbinani/screenshot"
    "image/png"
    "os"
    "fmt"
    
    
    unc 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)
    }
    
    
  • output example

     go run main.go
    0 : (0,0)-(1280,800) "0_1280x800.png"
    1 : (-293,-1440)-(2267,0) "1_2560x1440.png"
    2 : (-1373,-1812)-(-293,108) "2_1080x1920.png"
     ls -1
    _1280x800.png
    _2560x1440.png
    _1080x1920.png
    ain.go
    

coordinate

Y-axis is downward direction in this library. The origin of coordinate is upper-left corner of main display. This means coordinate system is similar to Windows OS

license

MIT Licence

author

kbinani

Open Source Agenda is not affiliated with "Screenshot" Project. README Source: kbinani/screenshot
Stars
1,151
Open Issues
1
Last Commit
8 months ago
Repository
License
MIT

Open Source Agenda Badge

Open Source Agenda Rating