File changes ignored or skipped

I am attempting to use a shell script to automatically run jpegoptim (http://www.kokkonen.net/tjko/projects.html) on all files added or changed in a folder. Sometimes the script is triggered, sometimes it is not. I suspect a subtlety in Hazel's change detection heuristic. Here are the clues I have so far:
- Works: Copy a new JPEG into the folder.
- Fails: Copy the same JPEG into the folder again, replacing the existing, optimized JPEG.
- Works: Delete the JPEG, wait at least 10 seconds, and copy the same JPEG again.
- Fails: Delete the JPEG, wait 2 seconds or less, and copy the same JPEG again (this occasionally works).