PNG was replaced by JPEG because of smaller image sizes. ~11.5KB for PNG vs just <2KB for JPEG with 20% quality.

This commit is contained in:
Alexander Andreev 2022-08-28 23:30:38 +04:00
parent c90f5db3a8
commit ae67f6aa4f
Signed by: Arav
GPG Key ID: 0388CC8FAA51063F

View File

@ -2,7 +2,7 @@ package handlers
import (
"fmt"
"image/png"
"image/jpeg"
"justcaptcha/internal/captcha"
pcaptcha "justcaptcha/pkg/captcha"
"justcaptcha/pkg/server"
@ -38,7 +38,7 @@ func (h *CaptchaHandlers) Image(w http.ResponseWriter, r *http.Request) {
w.Header().Add("Content-Disposition", "inline; filename=\""+string(captchaID)+"\"")
png.Encode(w, *captchaImage)
jpeg.Encode(w, *captchaImage, &jpeg.Options{Quality: 20})
}
func (h *CaptchaHandlers) Solve(w http.ResponseWriter, r *http.Request) {