From ae67f6aa4f14935a177add7b9fcffff36a6a196b Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Sun, 28 Aug 2022 23:30:38 +0400 Subject: [PATCH] PNG was replaced by JPEG because of smaller image sizes. ~11.5KB for PNG vs just <2KB for JPEG with 20% quality. --- internal/handlers/handlers.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/handlers/handlers.go b/internal/handlers/handlers.go index fc797ea..2428788 100644 --- a/internal/handlers/handlers.go +++ b/internal/handlers/handlers.go @@ -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) {