I'm using pptx to run quality checks on some powerpoint presentations. I have to check if specific image is present in a presentation, however I'm finding it even in presentations where it's not present or where there actually are no images at all. This is the function i'm using, where gt_bytes are the bytes of the ground truth image i need to check exists.
def check_image_existance(gt_bytes: bytes, ppt: Presentation) -> list[dict]:
found_images = []
shapes = []
for slide_id, slide in enumerate(ppt.slides):
for shape_id, shape in enumerate(slide.shapes):
# image type
if shape.shape_type == 13 or shape.shape_type == 14:
if hasattr(shape, 'image'):
image = shape.image
image_bytes = image.blob
if gt_bytes == image_bytes:
found_images.append({'slide_id':slide_id, 'shape_id':shape_id})
shapes.append(shape)
I'm exploring the found shapes properties but i cannot find anything that tells me whether they are visible or not. I have also checked if they are outside the bounds of the slide but that's not the case. All the images fall into the slide_type 13 so they are not placeholders.