-
Type:
Enhancement
-
Resolution: Unresolved
-
Priority:
P4
-
Affects Version/s: None
-
Component/s: client-libs
-
None
ImageIO.read(jpegFile) is several times slower than it needs to be.
The attached `JPEG_Progressive.java` benchmark produces this output on my MacBook Pro, running JDK 26 (internal):
Benchmark Mode Cnt Score Error Units
JPEG_Progressive.measureImageConsumer avgt 15 62.919 ± 2.717 ms/op
JPEG_Progressive.measureImageIO avgt 15 330.309 ± 9.658 ms/op
Here the "ImageConsumer" approach uses the older ImageProducer/ImageConsumer classes to create a BufferedImage in less than 20% of the time ImageIO requires.
If the JPEGImageDecoder can correctly read a file in ~60ms, then I'd expect the JPEGImageReader should be able to read the same file in at *most* ~120ms. The fact that it requires 5x that suggests something unusually wasteful is happening.
(FWIW: I surveyed about 9 common image formats (exported via Adobe Photoshop), and progressive JPG (rendered through ImageIO) is by far the most extreme outlier.)
The attached `JPEG_Progressive.java` benchmark produces this output on my MacBook Pro, running JDK 26 (internal):
Benchmark Mode Cnt Score Error Units
JPEG_Progressive.measureImageConsumer avgt 15 62.919 ± 2.717 ms/op
JPEG_Progressive.measureImageIO avgt 15 330.309 ± 9.658 ms/op
Here the "ImageConsumer" approach uses the older ImageProducer/ImageConsumer classes to create a BufferedImage in less than 20% of the time ImageIO requires.
If the JPEGImageDecoder can correctly read a file in ~60ms, then I'd expect the JPEGImageReader should be able to read the same file in at *most* ~120ms. The fact that it requires 5x that suggests something unusually wasteful is happening.
(FWIW: I surveyed about 9 common image formats (exported via Adobe Photoshop), and progressive JPG (rendered through ImageIO) is by far the most extreme outlier.)