https://github.com/skanehira/clipboard-image
Write to and read from image in clipboard
https://github.com/skanehira/clipboard-image
go golang
Last synced: 11 months ago
JSON representation
Write to and read from image in clipboard
- Host: GitHub
- URL: https://github.com/skanehira/clipboard-image
- Owner: skanehira
- License: mit
- Created: 2020-08-06T01:58:01.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2022-10-28T19:26:37.000Z (over 3 years ago)
- Last Synced: 2025-04-09T12:11:44.939Z (about 1 year ago)
- Topics: go, golang
- Language: Go
- Homepage:
- Size: 43 KB
- Stars: 24
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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.
```go
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.
```go
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