How to delete attachments/images from an email without deleting the email itself (Gmail)?

I’ve received a bunch of emails with large attachments and images. I want to keep the emails (including their headers) for my records, but I don’t want the attachments and images using up my allotment of storage on Google’s servers. I also want to keep my backups small, and they add unneeded bulk to my backup files.

In Gmail, how can one delete attachments/images from emails without deleting the email itself?

To keep this QA generic enough to help everyone, answers addressing sent and/or received emails are fine.