Created
November 8, 2020 06:47
-
-
Save romanitalian/b197531da5f32870e15f33a040078961 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ( | |
"bytes" | |
"image" | |
"image/color" | |
"image/draw" | |
"image/jpeg" | |
... | |
) | |
buf := new(bytes.Buffer) | |
m := image.NewRGBA(image.Rect(0, 0, 16, 16)) | |
clr := color.RGBA{B: 0, A: 0} | |
draw.Draw(m, m.Bounds(), image.NewUniform(clr), image.ZP, draw.Src) | |
jpeg.Encode(buffer, img, nil) | |
w.Header().Set("Content-Type", "image/jpeg") | |
w.Header().Set("Content-Length", strconv.Itoa(len(buffer.Bytes()))) | |
w.Write(buf.Bytes()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment