1
0
mirror of https://github.com/imgproxy/imgproxy.git synced 2024-11-24 08:12:38 +02:00
imgproxy/ico_data.go
2018-12-02 19:06:16 +06:00

29 lines
488 B
Go

package main
import (
"bytes"
"image"
"image/draw"
_ "github.com/mat/besticon/ico"
)
func icoData(data []byte) (out []byte, width int, height int, err error) {
var ico image.Image
ico, _, err = image.Decode(bytes.NewReader(data))
if err != nil {
return
}
// Ensure that image is in RGBA format
rgba := image.NewRGBA(ico.Bounds())
draw.Draw(rgba, ico.Bounds(), ico, image.ZP, draw.Src)
width = rgba.Bounds().Dx()
height = rgba.Bounds().Dy()
out = rgba.Pix
return
}