Browse Source

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)
tags/v0.20.0
Stephen Hu 3 months ago
parent
commit
2b7adbd2d1
No account linked to committer's email address
1 changed files with 5 additions and 5 deletions
  1. 5
    5
      rag/app/presentation.py

+ 5
- 5
rag/app/presentation.py View File

with slides.Presentation(BytesIO(fnm)) as presentation: with slides.Presentation(BytesIO(fnm)) as presentation:
for i, slide in enumerate(presentation.slides[from_page: to_page]): for i, slide in enumerate(presentation.slides[from_page: to_page]):
try: 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: except RuntimeError as e:
raise RuntimeError(f'ppt parse error at page {i+1}, original error: {str(e)}') from e raise RuntimeError(f'ppt parse error at page {i+1}, original error: {str(e)}') from e
assert len(imgs) == len( assert len(imgs) == len(

Loading…
Cancel
Save