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/BurntSushi/toml"
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"idicon/icons"
|
"idicon/icons"
|
||||||
|
"image/jpeg"
|
||||||
"image/png"
|
"image/png"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -81,6 +82,9 @@ func requestHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
if ct == "svg" || cth == "image/svg+xml" {
|
if ct == "svg" || cth == "image/svg+xml" {
|
||||||
w.Header().Add("Content-Type", "image/svg+xml")
|
w.Header().Add("Content-Type", "image/svg+xml")
|
||||||
_, err = w.Write([]byte(iconGenerator.GenSvg(id, size)))
|
_, 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 {
|
} else {
|
||||||
w.Header().Add("Content-Type", "image/png")
|
w.Header().Add("Content-Type", "image/png")
|
||||||
err = png.Encode(w, iconGenerator.GenIcon(id, size))
|
err = png.Encode(w, iconGenerator.GenIcon(id, size))
|
||||||
|
@ -189,6 +189,7 @@
|
|||||||
<label for="contenttype">Content-Type</label>
|
<label for="contenttype">Content-Type</label>
|
||||||
<select id="contenttype" onchange="newcontenttype(this.value)">
|
<select id="contenttype" onchange="newcontenttype(this.value)">
|
||||||
<option value="png" selected>PNG</option>
|
<option value="png" selected>PNG</option>
|
||||||
|
<option value="jpeg">JPEG</option>
|
||||||
<option value="svg">SVG</option>
|
<option value="svg">SVG</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user