pdf to img: convert jpx to jpeg
Showing
1 changed file
with
9 additions
and
3 deletions
| ... | @@ -84,9 +84,15 @@ class PDFHandler: | ... | @@ -84,9 +84,15 @@ class PDFHandler: |
| 84 | def extract_single_image(self, pdf, xref, smask, colorspace, pno, img_index=0): | 84 | def extract_single_image(self, pdf, xref, smask, colorspace, pno, img_index=0): |
| 85 | pix = self.recover_pix(pdf, xref, smask, colorspace) | 85 | pix = self.recover_pix(pdf, xref, smask, colorspace) |
| 86 | ext, img_data = self.get_img_data(pix) | 86 | ext, img_data = self.get_img_data(pix) |
| 87 | img_save_path = self.get_img_save_path(pno, img_index=img_index, ext=ext) | 87 | if ext == 'jpx': |
| 88 | with open(img_save_path, "wb") as f: | 88 | img_save_path = self.get_img_save_path(pno, img_index=img_index, ext='jpeg') |
| 89 | f.write(img_data) | 89 | jpx_pix = fitz.Pixmap(img_data) |
| 90 | jpx_pix.writeImage(img_save_path) | ||
| 91 | jpx_pix = None | ||
| 92 | else: | ||
| 93 | img_save_path = self.get_img_save_path(pno, img_index=img_index, ext=ext) | ||
| 94 | with open(img_save_path, "wb") as f: | ||
| 95 | f.write(img_data) | ||
| 90 | self.xref_set.add(xref) | 96 | self.xref_set.add(xref) |
| 91 | self.img_path_list.append(img_save_path) | 97 | self.img_path_list.append(img_save_path) |
| 92 | 98 | ... | ... |
-
Please register or sign in to post a comment