Can't get the picture in the header

I am trying to extract the pictures from the header of a word document. But it doesn’t seems to always work. I would like to know if there was a way to get them 100% of the time, thank you ( i am using aspose word python). Here is my code to extract all pictures from a document :

image_index =1
for node in doc.get_child_nodes(aw.NodeType.ANY, True):
        if node.node_type == aw.NodeType.SHAPE or node.node_type == aw.NodeType.GROUP_SHAPE:
            image_file_name = image_recup(node, image_index)
            image_index += 1

and here is function image_recup :

def image_recup(node, image_index):
    # Créer un dossier pour enregistrer les images
    if not os.path.exists("images"):
        os.makedirs("images")
    # Enregistrer l'image dans le dossier avec un nom unique
    image_file_name = f"images/image_{image_index}.png"
    node.as_shape().image_data.save(image_file_name)
    with Image.open(image_file_name) as img:
        img.save(image_file_name)
    return image_file_name

@lchevallier1299 Could you please attach the problematic document where your code does not work as expected? We will check the issue and provide you more information.

yes here it is !
LAF_Groupathlon 2 V0.docx (31,7 Ko)

@lchevallier1299 In your code you it is supposed to process both shapes and group shapes. In such case I would suggest to modify the code like this:

doc = aw.Document("C:\\Temp\\in.docx")

image_index = 1
for node in doc.get_child_nodes(aw.NodeType.ANY, True):
    # Process shape
    if node.node_type == aw.NodeType.SHAPE:
        s = node.as_shape()
        if s.is_top_level:
            s.get_shape_renderer().save(f"C:\\Temp\\shape_{image_index}.png", aw.saving.ImageSaveOptions(aw.SaveFormat.PNG))
            image_index = image_index+1
    # process group shape
    elif node.node_type == aw.NodeType.GROUP_SHAPE:
        g = node.as_group_shape()
        if g.is_top_level:
            g.get_shape_renderer().save(f"C:\\Temp\\shape_{image_index}.png", aw.saving.ImageSaveOptions(aw.SaveFormat.PNG))
            image_index = image_index+1