Commit 53ccd5a6 authored by 赵小蒙's avatar 赵小蒙

fix: add try import opencv-python and Pillow

parent 17be5497
import fitz
import cv2
from PIL import Image
import numpy as np
from loguru import logger
from magic_pdf.model.model_list import MODEL
import magic_pdf.model as model_config
......@@ -23,6 +20,11 @@ def remove_duplicates_dicts(lst):
def load_images_from_pdf(pdf_bytes: bytes, dpi=200) -> list:
try:
import cv2
from PIL import Image
except ImportError:
logger.error("opencv-python and Pillow are not installed, please install by pip.")
images = []
with fitz.open("pdf", pdf_bytes) as doc:
for index in range(0, doc.page_count):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment