Open pioterj opened 11 years ago
I found even better example.
Imgscalr:
Photoshop:
Original:
Here the result from Photoshop is vastly superior.
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.
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:
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:
Photoshop:
Original: