The result of decoding an image format might not be an image.RGBA
: decoding a GIF results in an image.Paletted
, decoding a JPEG results in aycbcr.YCbCr
, and the result of decoding a PNG depends on the image data. To convert any image to an image.RGBA
:
b := src.Bounds() m := image.NewRGBA(b) draw.Draw(m, b, src, b.Min, draw.Src)