When you add an image to a Gramps record, it creates a checksum from the raw image file that is stored internally within Gramps. If you alter the file, as you note, there is a conflict with the checksum.
Any time you run the Check & Repair tool, these checksums will be updated. Tools >> Family Tree Repair >> Check and Repair Database.
There is also the Media Verify Tool. Tool >> Utilities >> Media Verify
This tool will scan all media files in your media directory and compare it to media records in Gramps. These checksum mismatches will show as missing raw files for the Gramps records and extra files in the media folders. The Fix will bring these files back together with the records.