don't accidentally downscale embedded images in-place while displaying previews

This commit is contained in:
xenofem 2024-08-04 00:59:48 -04:00
parent 75f31b83e9
commit 6a8c8c0f1d

View file

@ -742,6 +742,7 @@ def get_displayed_image_xref(page):
def display_sixel_pixmap(pixmap_bytes): def display_sixel_pixmap(pixmap_bytes):
s = BytesIO() s = BytesIO()
image = Image.open(BytesIO(pixmap_bytes)) image = Image.open(BytesIO(pixmap_bytes))
image.thumbnail(size=(800, 800))
width, height = image.size width, height = image.size
try: try:
@ -811,7 +812,6 @@ def pdf_image_extractors(pdf, strategy):
display_sixel_pixmap(page.get_pixmap(dpi=PDF_PREVIEW_DPI).tobytes('png')) display_sixel_pixmap(page.get_pixmap(dpi=PDF_PREVIEW_DPI).tobytes('png'))
if xref is not None: if xref is not None:
pixmap = fitz.Pixmap(pdf, xref) pixmap = fitz.Pixmap(pdf, xref)
pixmap.shrink(2)
display_sixel_pixmap(pixmap.tobytes('png')) 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] ')