Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kbinani/screenshot
Go library to capture desktop to image
https://github.com/kbinani/screenshot
golang screen-capture screenshot
Last synced: 8 days ago
JSON representation
Go library to capture desktop to image
- Host: GitHub
- URL: https://github.com/kbinani/screenshot
- Owner: kbinani
- License: mit
- Created: 2016-09-26T12:19:40.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2024-08-20T16:09:36.000Z (3 months ago)
- Last Synced: 2024-08-20T18:30:39.786Z (3 months ago)
- Topics: golang, screen-capture, screenshot
- Language: Go
- Size: 96.7 KB
- Stars: 1,234
- Watchers: 26
- Forks: 169
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
screenshot
==========![](https://github.com/kbinani/screenshot/actions/workflows/build.yml/badge.svg)
[![](https://img.shields.io/badge/godoc-reference-5272B4.svg)](https://godoc.org/github.com/kbinani/screenshot)
[![](https://img.shields.io/badge/license-MIT-428F7E.svg?style=flat)](https://github.com/kbinani/screenshot/blob/master/LICENSE)
[![Go Report Card](https://goreportcard.com/badge/github.com/kbinani/screenshot)](https://goreportcard.com/report/github.com/kbinani/screenshot)* 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`
```go
package mainimport (
"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)
}
}
```* output example
```bash
$ 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
0_1280x800.png
1_2560x1440.png
2_1080x1920.png
main.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 OSlicense
=======MIT Licence
author
======kbinani