Corrupted jpg.temp files from macro save

I’m using a macro to analyze 6 different regions of an image file. I want to save each of the 6 masked regions separately into an output directory. Using the macro command “save(outputDir+filename+”.jpg")," has yielded some confusing results.

If files of the same names exist in the directory already, the macro overwrites most of them with the new images, but will occasionally corrupt a file, saving it as “filename.jpg.temp.” It’s not consistent in which file is corrupted, and sometimes it runs without corrupting any. If there are no files in the directory, the program runs without error. If I manually change the file to be “filename.jpg,” it converts to the desired image.

I’m wondering if there are any explanations or work arounds for this. Thanks.

Hello faraguna -

Is it possible that you have antivirus software running?

I haven’t seen this specifically with Fiji / ImageJ, but some antivirus
scanners will temporarily (thus, the randomness) grab hold of a file,
preventing it from being modified / overwritten.

If you think this might be the case, try turning off your antivirus
software or try telling it not to scan / protect the directory to which
your macro is writing the .jpg files.

Thanks, mm

Woah I think this resolved the problem! Very cool, thanks!