Your
ImageResource
returned from
makeGray()
does not have a file name because it has been created in memory and
setFileName()
has not been called for it.
Use the name of the input file instead:
gray.setFileName(f.getParent() + f.pathSeperator + "copy-" + f.GetName());
If you need to save the file in a different directory use that instead of
f.getParent()
.