geosolutions-it / imageio-ext

Additional plugins and extension for the standard Java ImageIO library
Other
139 stars 80 forks source link

Fast Thumbnails #263

Open eGit opened 2 years ago

eGit commented 2 years ago

To get a thumbnail you need to decode the full picture and then scale it to thumbnail size. To overcome this obstacle the jpeg-format allows you to get a picture 1/2, 1/4, 1/8 or even 1/16 in size of the original picture. E.g. for a factor 1/8, a 5000x5000 picture will be returned as a 625x625 picture. Java does NOT offer this functionality (C++ libs like ijg do).

For jpeg thumbnails you just need the DC components and skip all the AC components. This means you only have to decrypt the DC component. You still have to do the full Huffman decompression, but still it saves a hell lot of time, disk I/O, memory and exceptions.

There are many implementations of this in C/C++. Are there any in Java? Could be a game-changer for apps that generate a lot of thumbnails.