From 348c0a32152bb4e641e6fab48c1218f5c8691980 Mon Sep 17 00:00:00 2001 From: krau <71133316+krau@users.noreply.github.com> Date: Sat, 30 Nov 2024 22:16:37 +0800 Subject: [PATCH] fix: incomplete data caused by buffer pool --- common/image.go | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/common/image.go b/common/image.go index cebb64b..9eb0ac6 100644 --- a/common/image.go +++ b/common/image.go @@ -275,15 +275,7 @@ func CompressImageForTelegramByFFmpegFromBytes(input []byte, maxDepth uint, extr } vfKwArg := ffmpeg.KwArgs{"vf": fmt.Sprintf("scale=%d:%d:flags=lanczos", newWidth, newHeight)} - buf := imageBufferPool.Get().(*bytes.Buffer) - buf.Reset() - defer func() { - buf.Reset() - imageBufferPool.Put(buf) - }() - if buf.Cap() < inputLen { - buf.Grow(inputLen - buf.Cap()) - } + buf := bytes.NewBuffer(nil) err = ffmpeg.Input("pipe:").Output("pipe:", vfKwArg, ffmpeg.KwArgs{"format": "mjpeg"}, ffmpeg.MergeKwArgs(extraFFmpegKwArgs)).WithInput(bytes.NewReader(input)).WithOutput(buf).Run()