Code Monkey home page Code Monkey logo

screenshot's Introduction

screenshot

Build Status Go Report Card

  • Go library to capture desktop screen.
  • Support Windows, Mac, Linux, FreeBSD, OpenBSD, NetBSD, and Solaris environment.
  • Multiple display supported.
  • cgo free for Windows, Linux, FreeBSD, OpenBSD, NetBSD, and Solaris.

example

  • sample program main.go

     package main
    
     import (
     	"github.com/brendanporter/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

     $ 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 OS

license

MIT Licence

author

kbinani

screenshot's People

Contributors

kbinani avatar

Watchers

Brendan Porter avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.