Skip to content

skanehira/clipboard-image

Repository files navigation

clipboard-image

Copy image to clipboard

Supported OS

  • Windows
  • Mac
  • Linux/Unix

Requirements

  • xclip(linux only)
  • file(linux only)

Install

go get github.com/skanehira/clipboard-image/v2

Usage

Copy image file to clipboard.

f, err := os.Open("image.png")
if err != nil {
	log.Fatal(err)
}
defer f.Close()

if err := clipboard.Write(f); err != nil {
	log.Fatal(err)
}

Read image file from clipboard.

r, err := clipboard.Read()
if err != nil {
	log.Fatal(err)
}

f, err := os.Create("image.png")
if err != nil {
	log.Fatal(err)
}
defer f.Close()

if _, err := io.Copy(f, r); err != nil {
	log.Fatal(err)
}

Author

skanehira

About

Write to and read from image in clipboard

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages