From 2b7adbd2d19d84b0c2d07d98a5c4840c62429e7b Mon Sep 17 00:00:00 2001 From: Stephen Hu Date: Fri, 11 Jul 2025 11:35:25 +0800 Subject: [PATCH] Fix: Improve Memory Usage For Presentation (#8792) ### What problem does this PR solve? https://github.com/infiniflow/ragflow/issues/8791 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- rag/app/presentation.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rag/app/presentation.py b/rag/app/presentation.py index 45f72adf5..03e89b075 100644 --- a/rag/app/presentation.py +++ b/rag/app/presentation.py @@ -40,11 +40,11 @@ class Ppt(PptParser): with slides.Presentation(BytesIO(fnm)) as presentation: for i, slide in enumerate(presentation.slides[from_page: to_page]): try: - buffered = BytesIO() - slide.get_thumbnail( - 0.5, 0.5).save( - buffered, drawing.imaging.ImageFormat.jpeg) - imgs.append(Image.open(buffered)) + with BytesIO() as buffered: + slide.get_thumbnail( + 0.5, 0.5).save( + buffered, drawing.imaging.ImageFormat.jpeg, quality=80) + imgs.append(Image.open(buffered)) except RuntimeError as e: raise RuntimeError(f'ppt parse error at page {i+1}, original error: {str(e)}') from e assert len(imgs) == len(