瀏覽代碼

Fix: fixed invalid save() arguments for slide thumbnails (#8851)

### What problem does this PR solve?

Fixed invalid save() arguments for slide thumbnails.

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
tags/v0.20.0
Yongteng Lei 3 月之前
父節點
當前提交
e9b14142a5
沒有連結到貢獻者的電子郵件帳戶。
共有 2 個檔案被更改,包括 7 行新增6 行删除
  1. 3
    2
      rag/app/presentation.py
  2. 4
    4
      rag/svr/task_executor.py

+ 3
- 2
rag/app/presentation.py 查看文件

with BytesIO() as buffered: with BytesIO() as buffered:
slide.get_thumbnail( slide.get_thumbnail(
0.5, 0.5).save( 0.5, 0.5).save(
buffered, drawing.imaging.ImageFormat.jpeg, quality=80)
imgs.append(Image.open(buffered))
buffered, drawing.imaging.ImageFormat.jpeg)
buffered.seek(0)
imgs.append(Image.open(buffered).copy())
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(

+ 4
- 4
rag/svr/task_executor.py 查看文件

d["image"].close() # Close original image d["image"].close() # Close original image
d["image"] = converted_image d["image"] = converted_image
d["image"].save(output_buffer, format='JPEG') d["image"].save(output_buffer, format='JPEG')
async with minio_limiter: async with minio_limiter:
await trio.to_thread.run_sync(lambda: STORAGE_IMPL.put(task["kb_id"], d["id"], output_buffer.getvalue())) await trio.to_thread.run_sync(lambda: STORAGE_IMPL.put(task["kb_id"], d["id"], output_buffer.getvalue()))
d["img_id"] = "{}-{}".format(task["kb_id"], d["id"]) d["img_id"] = "{}-{}".format(task["kb_id"], d["id"])
nursery.start_soon(delete_image, task_dataset_id, chunk_id) nursery.start_soon(delete_image, task_dataset_id, chunk_id)
progress_callback(-1, msg=f"Chunk updates failed since task {task['id']} is unknown.") progress_callback(-1, msg=f"Chunk updates failed since task {task['id']} is unknown.")
return return
logging.info("Indexing doc({}), page({}-{}), chunks({}), elapsed: {:.2f}".format(task_document_name, task_from_page, logging.info("Indexing doc({}), page({}-{}), chunks({}), elapsed: {:.2f}".format(task_document_name, task_from_page,
task_to_page, len(chunks), task_to_page, len(chunks),
timer() - start_ts)) timer() - start_ts))
finally: finally:
redis_lock.release() redis_lock.release()
await trio.sleep(30) await trio.sleep(30)
async def task_manager(): async def task_manager():
try: try:
await handle_task() await handle_task()

Loading…
取消
儲存