Spaces:
Sleeping
Sleeping
File size: 387 Bytes
8619a66 b6fadef | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | try:
import pymupdf as fitz
except ImportError:
import fitz
from PIL import Image
def pdf_to_images(pdf_bytes):
doc = fitz.open(stream=pdf_bytes, filetype="pdf")
images = []
for page in doc:
pix = page.get_pixmap(dpi=300)
img = Image.frombytes("RGB", [pix.width, pix.height], pix.samples)
images.append(img)
return images |