On my contact page, its a form where people can select a department to contact, then they fill out basic information (name, email and message).
Additionally, a PHP script is called (via the HTML IMG tag) to load an image that shows the digits one has to exactly type in a box to confirm the message composer is an actual human. The digits are randomly generated on every load. I can't use text to generate the random text or spam bots could detect the digits easier.
Having said all that, what I'm noticing in my server logs is that the google image bot is accessing this number-generating PHP script about once a week. I bet it is trying to index it as a user searchable image on the web.
I check google documentation on ways to specifically make the image (number-generating script) non-indexable and they were suggesting no-indexing the whole page the image is on.
I did read at https://moz.com/community/q/should-i-index-or-noindex-a-contact-page that not-indexing a contact page is not a good idea.
There was also a suggestion to block the file in robots.txt but this could entice hackers to try to spam the site more. I'd rather keep my robots.txt as clean as possible.
Is there an easy way to specifically make only one image in a page non-indexable and leave the rest of the links in the same page indexable?