Spaces:
Build error
Build error
Download src/processing/pdf_utils.py from redmelonberry/presentation-search: direct link, hf CLI and curl.
- Browser
- Download file 297 Bytes
-
https://huggingface.co/spaces/redmelonberry/presentation-search/resolve/main/src/processing/pdf_utils.py
- Command line
-
hf download hf://spaces/redmelonberry/presentation-search/src/processing/pdf_utils.py
-
curl -L -o pdf_utils.py https://huggingface.co/spaces/redmelonberry/presentation-search/resolve/main/src/processing/pdf_utils.py
297 Bytes
| import fitz | |
| from PIL import Image | |
| def page2image(page: fitz.Page, dpi: int = 72): | |
| # Convert page to pixmap | |
| pix = page.get_pixmap(dpi=dpi) | |
| # Convert pixmap to PIL Image | |
| img = Image.frombytes( | |
| "RGB", | |
| (pix.width, pix.height), | |
| pix.samples | |
| ) | |
| return img |