Skip to content

CaryQY/screenshot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Basic Usage

more usage please check "screenshot_linux_test.go" file

package main

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

func main() {
	shot, err := screenshot.New()
	if err != nil {
		fmt.Println(err)
		return
	}
	defer shot.Close()

	// custom save img to png
	{
		img, err := shot.CaptureScreen()
		if err != nil {
			fmt.Println(err)
			return
		}
		f, err := os.Create("./" + time.Now().Format("200601021504") + ".png")
		if err != nil {
			fmt.Println(err)
			return
		}
		defer f.Close()
		err = png.Encode(f, img)
		if err != nil {
			fmt.Println(err)
			return
		}
	}

	// save img to jpg
	{
		img, err := shot.GetScreen(75)
		if err != nil {
			fmt.Println(err)
			return
		}
		f, err := os.Create("./" + time.Now().Format("200601021504") + ".jpg")
		if err != nil {
			fmt.Println(err)
			return
		}
		defer f.Close()
		_, err = f.Write(img)
		if err != nil {
			fmt.Println(err)
			return
		}
	}
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages