diff --git a/dlibrary/dlibrary.py b/dlibrary/dlibrary.py index 67ba0ea..df518ff 100755 --- a/dlibrary/dlibrary.py +++ b/dlibrary/dlibrary.py @@ -678,9 +678,9 @@ def get_displayed_image_xref(page): debug(f"Multiple images found matching ref name {ref_names[0]}, that probably shouldn't happen") return None -def display_sixel_page(page): +def display_sixel_pixmap(pixmap_bytes): s = BytesIO() - image = Image.open(BytesIO(page.get_pixmap(dpi=PDF_PREVIEW_DPI).tobytes('png'))) + image = Image.open(BytesIO(pixmap_bytes)) width, height = image.size try: @@ -747,7 +747,11 @@ def pdf_images(pdf, strategy): break if choice.lower().startswith('s'): - display_sixel_page(page) + display_sixel_pixmap(page.get_pixmap(dpi=PDF_PREVIEW_DPI).tobytes('png')) + if xref is not None: + pixmap = fitz.Pixmap(pdf, xref) + pixmap.shrink(2) + display_sixel_pixmap(pixmap.tobytes('png')) choice = input(f'[N]ope out / [c]onvert page{"" if xref is None else " / e[x]tract image"} / [d]rop page / [s]how page? [n/c{"" if xref is None else "/x"}/d/s] ') print(f'\x1b[2K\r{idx+1}/{pdf.page_count} pages analyzed...', end=('' if idx+1 < pdf.page_count else '\n'))