0

I know there is already lot of discussion around this but haven't found the answer. I have no issues with reading image with ImageIO except it takes time.

I have 18-20MB images and it takes 10-20 seconds to read them. Are there any new image libraries which can help reading an image in BufferedImage faster than ImageIO?

Abra
  • 19,142
  • 7
  • 29
  • 41
plzdontkillme
  • 1,497
  • 3
  • 20
  • 38
  • Helpful reading: https://stackoverflow.com/a/20141447/1270000 – sorifiend Jul 30 '21 at 04:05
  • Java image objects are not compressed. Unless your images are BMPs or uncompressed TIFFs, each of them is going to take up a lot more program memory than just 20 MB. That memory usage may be contributing to your performance issues. Depending on what you’re doing with those images, you may be able to [read each image in small sections](https://docs.oracle.com/en/java/javase/16/docs/api/java.desktop/javax/imageio/IIOParam.html#setSourceRegion(java.awt.Rectangle)) to reduce memory usage. – VGR Jul 30 '21 at 13:53
  • Thanks for reply, I read the image and trying to identify if there is a border or not. Logic itself is very light but loading the big images itself takes time – plzdontkillme Jul 30 '21 at 14:03
  • Are the images by any chance progressive JPEGs? I know that these are very slow to read using ImageIO (the progressive update implementation is unreasonably slow, even if you don't care about progressive updates). In any case, it might help if you could share one of the files, as it is very unusual for an image to need 10-20 seconds to load. – Harald K Aug 02 '21 at 14:36
  • Thanks Harald, I have attached the smaller size of image, as stack overflow doesn't allows more than 2 mb of image, consider same image is of 9000X13000 pixels – plzdontkillme Aug 02 '21 at 21:57
  • As long as it exposes the problem, it doesn't have to be the same image. But if it shows different characteristics, it's not of much help... You don't need to upload to SO, perhaps only add a link to DropBox or a Gist or similar. In any case, I don't see any image attached? – Harald K Aug 03 '21 at 07:03

0 Answers0