Automated way to move Gmail image / video attachments to Google Photos

I’m running out of storage in my Google account. In order to save space, I’m trying to move many images and videos from Gmail into Google Photos with “high quality” (where Google Photos offers unlimited storage).

I know this can be done manually with some help from Google One storage management, but I’m looking for a way to automate a batch process of finding all image / video attachments in emails, uploading them to Google Photos, and deleting them from Gmail, while preserving the email thread.

Ideal outcome would be:

  1. Image and video attachments deleted from Gmail
  2. All text in emails preserved
  3. Image and video attachments uploaded to Google Photos
  4. links to the location of the attachments included in the email thread (in a way that doesn’t send an email to anyone else in the conversation or move the message back to my inbox)

If not all of this is possible, automating some of the items would be helpful. If there’s a script that does some of the work that I could modify, that could be a solution.

Things I’ve looked into already:

  1. gmail support: How can I move photo attachments in my email to
    google photos or google drive?
  2. Stack exchange question: Easy
    way to move photos from Gmail attachment to Google Photos
  3. Chrome extension: Save Image to Google Photo