when displaying a pdf page with a single image, also show the extracted image on its own for comparison
This commit is contained in:
parent
c4f5c776e2
commit
a822a504e8
|
@ -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")
|
debug(f"Multiple images found matching ref name {ref_names[0]}, that probably shouldn't happen")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def display_sixel_page(page):
|
def display_sixel_pixmap(pixmap_bytes):
|
||||||
s = BytesIO()
|
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
|
width, height = image.size
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -747,7 +747,11 @@ def pdf_images(pdf, strategy):
|
||||||
break
|
break
|
||||||
|
|
||||||
if choice.lower().startswith('s'):
|
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] ')
|
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'))
|
print(f'\x1b[2K\r{idx+1}/{pdf.page_count} pages analyzed...', end=('' if idx+1 < pdf.page_count else '\n'))
|
||||||
|
|
Loading…
Reference in a new issue