mirror of
https://github.com/pcvolkmer/idicon.git
synced 2025-04-19 16:46:50 +00:00
Add support for JPEG images
This commit is contained in:
parent
037f63466a
commit
0757e484f6
@ -7,6 +7,7 @@ import (
|
||||
"github.com/BurntSushi/toml"
|
||||
"github.com/gorilla/mux"
|
||||
"idicon/icons"
|
||||
"image/jpeg"
|
||||
"image/png"
|
||||
"log"
|
||||
"net/http"
|
||||
@ -81,6 +82,9 @@ func requestHandler(w http.ResponseWriter, r *http.Request) {
|
||||
if ct == "svg" || cth == "image/svg+xml" {
|
||||
w.Header().Add("Content-Type", "image/svg+xml")
|
||||
_, err = w.Write([]byte(iconGenerator.GenSvg(id, size)))
|
||||
} else if ct == "jpeg" || cth == "image/jpeg" {
|
||||
w.Header().Add("Content-Type", "image/webp")
|
||||
err = jpeg.Encode(w, iconGenerator.GenIcon(id, size), nil)
|
||||
} else {
|
||||
w.Header().Add("Content-Type", "image/png")
|
||||
err = png.Encode(w, iconGenerator.GenIcon(id, size))
|
||||
|
@ -189,6 +189,7 @@
|
||||
<label for="contenttype">Content-Type</label>
|
||||
<select id="contenttype" onchange="newcontenttype(this.value)">
|
||||
<option value="png" selected>PNG</option>
|
||||
<option value="jpeg">JPEG</option>
|
||||
<option value="svg">SVG</option>
|
||||
</select>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user