paste images with ctrl+v (#26)

This commit is contained in:
phantomreactor
2025-05-17 01:01:50 +05:30
committed by GitHub
parent b71cae63f1
commit ba416e787b
5 changed files with 278 additions and 2 deletions

View File

@@ -1,8 +1,10 @@
package image
import (
"bytes"
"fmt"
"image"
"image/png"
"os"
"strings"
@@ -71,3 +73,13 @@ func ImagePreview(width int, filename string) (string, error) {
return imageString, nil
}
func ImageToBytes(image image.Image) ([]byte, error) {
buf := new(bytes.Buffer)
err := png.Encode(buf, image)
if err != nil {
return nil, err
}
return buf.Bytes(), nil
}