Add GIF image format

This commit is contained in:
Paul-Christian Volkmer 2024-09-29 01:24:56 +02:00
parent 59e4dce4e3
commit 43719eba8b
2 changed files with 5 additions and 0 deletions

View File

@ -7,6 +7,7 @@ import (
"github.com/BurntSushi/toml"
"github.com/gorilla/mux"
"idicon/icons"
"image/gif"
"image/jpeg"
"image/png"
"log"
@ -85,6 +86,9 @@ func requestHandler(w http.ResponseWriter, r *http.Request) {
} else if ct == "jpeg" || cth == "image/jpeg" {
w.Header().Add("Content-Type", "image/jpeg")
err = jpeg.Encode(w, iconGenerator.GenIcon(id, size), nil)
} else if ct == "gif" || cth == "image/gif" {
w.Header().Add("Content-Type", "image/gif")
err = gif.Encode(w, iconGenerator.GenIcon(id, size), nil)
} else {
w.Header().Add("Content-Type", "image/png")
err = png.Encode(w, iconGenerator.GenIcon(id, size))

View File

@ -190,6 +190,7 @@
<select id="contenttype" onchange="newcontenttype(this.value)">
<option value="png" selected>PNG</option>
<option value="jpeg">JPEG</option>
<option value="gif">GIF</option>
<option value="svg">SVG</option>
</select>
</div>