We should use ImageReadParam.setSourceSubsampling() in the ImageLoader.readImageFromStream() code to improve performance of creating thumbnails from large JPEG image files. The idea is that we can use subsampling to reduce the initial cost of reading the image (and reduce memory consumption) and then use the usual multi-step downscaling algorithm for the remaining part of the process so that we still produce a high-quality thumbnail.
For example, creating a 80x60 thumbnail from a 4000x3000 pixel image, we can use 8:8 subsampling so that Image I/O reads a 500x375 image, and then we use the multi-step algorithm to scale that down into an 80x60 thumbnail image.
We'll need to experiment to find the right balance between speed and quality.
Also, there is some overlap here with RT-2365... It appears that the CLibJPEGImageReader from JAI IIO Tools does not support native subsampling, so enabling can actually result in slower reading than not using it at all. If we are to pursue RT-2365, we'll need to add native subsampling support there first.