I'd guess it is not correctly handling file names with quotes or embedded spaces.
Have your program display the command line before trying to load the file.
Compile that and see what the file name looks like when you double click the image file.
Have your program display the command line before trying to load the file.
Compile that and see what the file name looks like when you double click the image file.