I'm late for the party, but anyway ...
Actually, using:
ImageIO.read(new File(basePath + imageSource));
and
ImageIO.write(bufferedImage, "jpeg", new File(fullPath));
... might turn out to be faster (try using the profiler to make sure).
This is because these options use RandomAccessFile -backed ImageInputStream / ImageOutputStream implementations behind the scenes, and versions with InputStream / OutputStream support will use the search stream implementation with disk support by default. Backing up a disk involves writing the entire contents of a stream to a temporary file and possibly reading it (this is because image input / output operations often benefit from non-linear data access).
If you want to avoid additional input-output operations with streaming versions, due to the use of more memory, you can call the ambiguously named ImageIO.setUseCache(false) to disable caching of input search streams. This, of course, is not a good idea if you are dealing with very large images.
haraldK
source share