optimizations + clean some code

This commit is contained in:
KingKDot
2026-05-21 23:28:06 -05:00
parent 06b001e5a1
commit bd47b233d6
7 changed files with 189 additions and 120 deletions
@@ -27,3 +27,15 @@ func encodeJPEG(img image.Image, quality int) ([]byte, error) {
jpegBufPool.Put(buf)
return out, nil
}
func encodeJPEGToBuf(dst *bytes.Buffer, img image.Image, quality int) error {
buf := jpegBufPool.Get().(*bytes.Buffer)
buf.Reset()
if err := jpeg.Encode(buf, img, &jpeg.Options{Quality: quality}); err != nil {
jpegBufPool.Put(buf)
return err
}
dst.Write(buf.Bytes())
jpegBufPool.Put(buf)
return nil
}