90 lines
1.8 KiB
Go
90 lines
1.8 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
// "image"
|
|
"image/jpeg"
|
|
// "bytes"
|
|
"log"
|
|
"os"
|
|
"strconv"
|
|
// "github.com/esimov/stackblur-go"
|
|
// "github.com/diamondburned/gotk4/pkg/gtk/v4"
|
|
// "github.com/diamondburned/gotk4/pkg/gdkpixbuf/v2"
|
|
// "github.com/diamondburned/gotk4/pkg/cairo"
|
|
// "github.com/diamondburned/gotk4/pkg/gdk/v4"
|
|
// "github.com/diamondburned/gotkit/gtkutil/imgutil"
|
|
)
|
|
|
|
func DownloadCoverArtFullSize(coverID string) {
|
|
|
|
path := GetRunDir() + MainDir + DataDir + "/" + coverID + ".jpg"
|
|
|
|
fil, err1 := os.OpenFile(path, os.O_APPEND|os.O_WRONLY, 0664)
|
|
defer fil.Close()
|
|
if err1 != nil {
|
|
//
|
|
param := map[string]string{"size": strconv.Itoa(int(MainSettings.Coversize))}
|
|
|
|
img, _ := CurrentClient.GetCoverArt(coverID, param)
|
|
fmt.Println("No such album downloaded: ", coverID)
|
|
f, err := os.Create(path)
|
|
// fb, err := os.Create(path2)
|
|
PanicOnError(err)
|
|
defer f.Close()
|
|
if err = jpeg.Encode(f, img, nil); err != nil {
|
|
log.Printf("failed to encode: %v", err)
|
|
|
|
}
|
|
|
|
// w, h := MainAlbumCover.GetSizeRequest()
|
|
|
|
// catFile, err := os.Open(path)
|
|
// if err != nil {
|
|
// panic(err)
|
|
// }
|
|
|
|
// defer catFile.Close()
|
|
// _, _, err = image.Decode(catFile)
|
|
// if err != nil {
|
|
// panic(err)
|
|
// }
|
|
|
|
// cat, err := jpeg.Decode(catFile)
|
|
// if err != nil {
|
|
// panic(err)
|
|
// }
|
|
|
|
// fmt.Println(cat)
|
|
// sig := make(chan struct{})
|
|
// img2 := stackblur.Process(cat, uint32(w), uint32(h), uint32(30), sig)
|
|
// select {
|
|
|
|
// case <-sig:
|
|
// jpeg.Encode(fb, img2, nil)
|
|
// }
|
|
} else {
|
|
|
|
fmt.Println("Album present: ", coverID)
|
|
}
|
|
|
|
}
|
|
|
|
// func LoadImageToByteArray(path string) []byte {
|
|
|
|
// f, err := os.Open(path)
|
|
// if err != nil {
|
|
// LogOnError(err)
|
|
// }
|
|
// defer f.Close()
|
|
// buf := new(bytes.Buffer)
|
|
// img, err := jpeg.Decode(f)
|
|
// err = jpeg.Encode(buf,img,nil)
|
|
|
|
// if err != nil {
|
|
// LogOnError(err)
|
|
// }
|
|
|
|
// return buf.Bytes()
|
|
// }
|