-
-
Notifications
You must be signed in to change notification settings - Fork 387
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
Improve quality of images #488
Comments
Ok, I will take a look and try to understand how it could be improved |
@akosourov are you working on this in any way? I am quite interested and want to solve it |
@mullakhmetov Yeah, sure. I tried to solve it two weeks ago but stopped and planned to continue on weekends. Ok, I don't mind :) |
Current resize implementation uses Quality comparisonText image
Cat image
Green image
I see the difference between Size comparisonText imageSource image size: 673KB
Cat imageSource image size: 817KB
Green imageSource image size: 1.6MB
BenchmarksAbout the Text image
Cat image
Green image
ConclusionSo, due to clear quality advantages of |
CatmullRom is better than BiLinear, Lanczos3 looks a little better than both, but text image quality after resize is still awful. Can we play around with the quality settings to get a more decent image? |
I still think this is not really due to scaling algo, but something about the ratio |
I can't get any more decent scaling result even in Photoshop. I tried to crop source image to Do you have some references? Maybe it is impossible to do better for such a small destination image size? |
btw, if the problem related to the small final size (800/300 default) we can increase it in cli/env (ImageGroup.ResizeWidth and ResizeHeight) |
Agree. But in your example image was scaled down with ~2.7 factor (from Here's CatmullRom-scaled to the same as github's size: Pretty close to the reference and certainly readable.
BiLinear algo is always much worse than CatmullRom, Lanczos3 is always a little better than the CatmullRom (in quality terms). But you are right, this is becoming a problem only with high scale factor.
Hmm. Image in original post downscaled to |
To clarify, GitHub image above is 1746x1790, it's scaled in render but is not altered in quality at all. |
https://github.com/umputun/remark/blob/master/backend/app/store/image/image.go#L174 |
I mean GitHub presents the original picture and it's up to the browser to scale it, and we are playing a completely different game here. If we do resize, let's not look at GitHub example and rather check what is desired quality vs size of a picture we are willing to store. |
I'm not sure why browser scaling is a "completely different game". If it can downscale the image to the proper size and keep it readable, what prevents us to do a similar thing on the backend side? |
just to clarify - I don't really care if we have to keep a larger image in order to make it readable. If the only way is to downscale it to some 1200/1200 - so be it |
I still don't get why the OP image dimensions so small. They both are lower than the corresponding default limits. It is posible only if source image dimensions were under limits and resize make no sense. Or |
as far as I recall dimensions adjusted on both X and Y. 300 is the max height so, it was downscaled from whateverW-whateverY to (max 800 W)- (max 300 Y) |
Ohh, I am sorry, I misread default limits (at least twice) and thought they are 800x600. |
|
The problem is not scaling algorithms themselves but scaling to serve for retina displays. |
Please review and approve PR #526 (comprehensively tested).
Example |
Can we resolve this one after merging #526? |
not sure. Maybe switching to CatmullRom will give us something good. Will be nice to see side-by-side with high res resize |
What do you mean by "high res resize"? Something like downscale 4000x3000 image with 2400x900 limits? |
Source and ApproxBiLinear, BiLinear, CatmullRom and Lanczos3 for the reference from top to bottom side-by-side
Browser knows device pixel ratio and use it to get physical linear resolution from logical height and width CSS properties. In other words |
№1 is worst (too sharp), №3 and №4 are the same and better than №2 (too blurry) is you'd ask me. |
Correct |
@mullakhmetov, thank you very much! Would you be so kind as to repeat your research and show four algorithms side-by-side? If you don't mind, better as separate pictures so it would be possible to cycle through them. |
It's not easy to find suitable (by license and for comparison) ~12mpx picture, as it turned out. |
|
keep in mind there's no Lanczos3 implementation in stdlib |
Let’s switch to CatmullRom then, could you please prepare a PR for that? |
Looks like resized images with text in are very hard to read, super blurry. It is unclear what the reason - could be non-proportional ratio, could be the resizing method. Github, for instance, makes images more readable.
This is an example of the blurry one: https://remark42.radio-t.com/api/v1/picture/github_ef0f706a79cc24b17bbbb374cd234a691d034128/bnmk3aqhajfjbc6s020g.png
The text was updated successfully, but these errors were encountered: