Skip to content

Commit

Permalink
Merge branch 'main' into iss2208
Browse files Browse the repository at this point in the history
  • Loading branch information
pubpub-zz authored Sep 26, 2023
2 parents 2e89609 + 41ffc2c commit 16ab46b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions pypdf/_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
NullObject,
NumberObject,
RectangleObject,
StreamObject,
)

MERGE_CROP_BOX = "cropbox" # pypdf<=3.4.0 used 'trimbox'
Expand Down Expand Up @@ -509,6 +510,8 @@ def _get_ids_image(

x_object = obj[PG.RESOURCES][RES.XOBJECT].get_object() # type: ignore
for o in x_object:
if not isinstance(x_object[o], StreamObject):
continue
if x_object[o][IA.SUBTYPE] == "/Image":
lst.append(o if len(ancest) == 0 else ancest + [o])
else: # is a form with possible images inside
Expand Down
5 changes: 3 additions & 2 deletions tests/test_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import pytest
from PIL import Image, ImageChops, ImageDraw

from pypdf import PdfReader
from pypdf._page import PageObject
from pypdf import PageObject, PdfReader
from pypdf.generic import NameObject, NullObject

from . import get_data_from_url

Expand Down Expand Up @@ -218,4 +218,5 @@ def test_loop_in_image_keys():
url = "https://github.com/py-pdf/pypdf/files/12309492/example_134.pdf"
name = "iss2077.pdf"
reader = PdfReader(BytesIO(get_data_from_url(url, name=name)))
reader.pages[0]["/Resources"]["/XObject"][NameObject("/toto")] = NullObject()
reader.pages[0].images.keys()

0 comments on commit 16ab46b

Please sign in to comment.