How to download signature image received as form input using python?

Hello,

I’m trying to download image using python. When I export my monday board to excel, I have a hyperlink of signature image which was received as a form input.

The hyperlink inside the excel is private link like this:

https://[company_name].monday.com/protected_static/15600435/resources/1433077819/signature.png

If I just copy this link to the browser, the signature image download begins automatically. However, I want to be able to have the access to the original signature image using Python.

If I try this in my python code, it fails to detect the image format because what is returned with the above hyperlink is the HTML triggering image download instead of the actual image:

    response = requests.get(student_signature, allow_redirects=True)

    # Check if the request was successful
    if response.status_code == 200:

        # Check if the response contains image data
        if "image" in response.headers.get("content-type", "").lower():
            # Determine the image format
            image_format = imghdr.what(None, response.content)

            if image_format:
                # Open the image using PIL
                image = Image.open(BytesIO(response.content))

                # Save the image
                image.save("signature." + image_format)
                print("Image saved successfully.")
            else:
                print("Failed to identify the image format.")
        else:
            print("The URL does not point to an image.")
    else:
        print("Failed to fetch the image.")

Any input is appreicated.

Thanks

1 Like