Spaces:
Build error
Build error
Update utils.py
Browse files
utils.py
CHANGED
|
@@ -6,13 +6,12 @@ import uuid
|
|
| 6 |
import pypdfium2 as pdfium
|
| 7 |
from PIL import Image
|
| 8 |
|
| 9 |
-
def convert2img(
|
| 10 |
-
|
| 11 |
-
page =
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
img = cv2.cvtColor(img, cv2.COLOR_RGBA2BGR)
|
| 16 |
return img
|
| 17 |
|
| 18 |
def save_image(img):
|
|
|
|
| 6 |
import pypdfium2 as pdfium
|
| 7 |
from PIL import Image
|
| 8 |
|
| 9 |
+
def convert2img(path):
|
| 10 |
+
pdf = pdfium.PdfDocument(path)
|
| 11 |
+
page = pdf.get_page(0)
|
| 12 |
+
pil_image = page.render().to_pil()
|
| 13 |
+
pl1=np.array(pil_image)
|
| 14 |
+
img = cv2.cvtColor(pl1, cv2.COLOR_RGB2BGR)
|
|
|
|
| 15 |
return img
|
| 16 |
|
| 17 |
def save_image(img):
|