File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -457,6 +457,10 @@ def extract_images_from_page(self, page: pypdf._page.PageObject) -> str:
457
457
logger .warning ("Unknown PDF Filter!" )
458
458
if np_image is not None :
459
459
image_bytes = io .BytesIO ()
460
+
461
+ if image_bytes .getbuffer ().nbytes == 0 :
462
+ continue
463
+
460
464
Image .fromarray (np_image ).save (image_bytes , format = "PNG" )
461
465
blob = Blob .from_data (image_bytes .getvalue (), mime_type = "image/png" )
462
466
image_text = next (self .images_parser .lazy_parse (blob )).page_content
@@ -1108,6 +1112,9 @@ def _extract_images_from_page(
1108
1112
pix .height , pix .width , - 1
1109
1113
)
1110
1114
image_bytes = io .BytesIO ()
1115
+ if image_bytes .getbuffer ().nbytes == 0 :
1116
+ continue
1117
+
1111
1118
numpy .save (image_bytes , image )
1112
1119
blob = Blob .from_data (
1113
1120
image_bytes .getvalue (), mime_type = "application/x-npy"
You can’t perform that action at this time.
0 commit comments