Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Imgscalr generates blurred thumbnails #92

Open
pioterj opened this issue Aug 25, 2013 · 3 comments
Open

Imgscalr generates blurred thumbnails #92

pioterj opened this issue Aug 25, 2013 · 3 comments

Comments

@pioterj
Copy link

pioterj commented Aug 25, 2013

Thanks for creating and sharing this nice library. I use it on my website to generate thumbnails. I'm generally happy with thumbnail quality but I noticed that there are slightly blurred compared to images scaled down in Photoshop or Gimp. For some images it is more noticeable than others. I'm using ULTRA_QUALITY option and I couldn't find any options that would improve the quality of thumbnails further. I'm attaching an example of a thumbnail that looks much better when created in Photoshop or Gimp than in Imgscalr as well as original image.

Imgscalr:
sample-imgscalr

Photoshop:
sample-photoshop

Original:
sample-original

@pioterj
Copy link
Author

pioterj commented Sep 1, 2013

I found even better example.

Imgscalr:
sample-scalr

Photoshop:
sample-photoshop

Original:
sample

Here the result from Photoshop is vastly superior.

@ghost
Copy link

ghost commented Sep 16, 2013

What I have in my head to address this is an progressive scaling algorithm.

Every time an image is scaled down a step, data is lost and the scaling algorithm is in charge of estimating the result. The bigger the scale difference, the bigger the loss of data in a single operation.

Right now the incremental scaling jumps down the currentDimension/7 (for ULTRA) or /2 (for anything else).

This means the biggest the image is the bigger the initial jumps down are and as the image approaches it's target size (typically a thumbnail) the jumps down are smaller and smaller.

A more optimal approach to incremental scaling is the exact opposite of this; the initial jumps down should be the smallest jumps losing the least amount of information and as the image gets smaller and smaller (losing more and more info) the jumps can be bigger because we have already lost the majority of info and averaged it).

I have not proof-of-concepted this approach yet so I don't know the real-world impact yet, but I SUSPECT this will provide a better quality result just thinking through it.

@rmuller
Copy link

rmuller commented Sep 18, 2016

Just tried the same image as used by @pioterj with the latest Scalr code (commit 2fac6c4) and Scalr.Method.ULTRA_QUALITY. I can confirm it is still much more blurred than the Photoshop thumbnail. The problem is the interpolation method available in default Java. Scalr uses the best available when QUALITY method is selected. To improve this, you need better (more advanced) techniques. A very nice implementation is found here: https://github.com/haraldk/TwelveMonkeys/blob/master/common/common-image/src/main/java/com/twelvemonkeys/image/ResampleOp.java

When using the TwelveMonkeys lanczos filter, this is the result:
rl-12m

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants