1
0
mirror of https://github.com/imgproxy/imgproxy.git synced 2025-01-08 10:45:04 +02:00
imgproxy/ico_data.go

29 lines
488 B
Go
Raw Normal View History

2018-12-02 15:02:19 +02:00
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
}