elastic / elastic/thumbnails4j

ImageThumbnailer.imageAtMost() should use subsampling

Open
#57 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
26
Forks
10
PR merge metrics
No merged PRs in 30d

Description

Currently, creating a thumbnail from a large image requires configuring a relatively large in-memory buffer. If the buffer is too small, the source image is only partially read and the resulting thumbnail is cropped.

Instead of limiting the source region, would it make sense to use image subsampling when the source image exceeds the configured in-memory dimensions? This would allow the full image to be preserved while reducing the amount of memory required during decoding.

Relevant code:

https://github.com/elastic/thumbnails4j/blob/c39f7fc142c6b12de36f77d7f89c127138f174d0/thumbnails4j-image/src/main/java/co/elastic/thumbnails4j/image/ImageThumbnailer.java#L94-L109

`ImageReadParam#setSourceSubsampling(...)` could potentially be used to decode a lower-resolution version of the entire image before applying the final thumbnail scaling:

https://docs.oracle.com/javase/8/docs/api/javax/imageio/IIOParam.html#setSourceSubsampling-int-int-int-int-

Contributor guide

Open the contributing guide

Research direction

Start in thumbnails4j-image/src/main/java/co/elastic/thumbnails4j/image/ImageThumbnailer.java at lines 94-109, where imageAtMost() limits decoding. Read ImageReadParam#setSourceSubsampling(...) and trace how the source region is currently selected. Done means a source image larger than the configured in-memory dimensions is decoded at lower resolution while the full image remains represented in the resulting thumbnail.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
computer-graphics
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.