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

Antialiasing not working correctly #183

Open
charbelnicolas opened this issue Aug 29, 2024 · 5 comments
Open

Antialiasing not working correctly #183

charbelnicolas opened this issue Aug 29, 2024 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@charbelnicolas
Copy link

Hi Artem, I've noticed that the current implementation of the antialiasing doesn't work correctly. I've made a comparison of a thumbnail antialiased by swayimg against imagemagick's cubic filter and there is a massive difference.

I have set my thumbnails to a 300 x 300 pixel size so I ran this command on the images with imagemagick:

magick image_file.jpg -resize 300x300^ -filter cubic -gravity center -extent 300x300 image_file.png

ss_2024_08_29_00_48_47

Please check the top row images and compare the left image (swayimg scaling) with the right image (imagemagick scaling). The jagermeister image is inverted, the right image is swayimg's scaling and the left one is imagemagick's scaling.

I think the scaling/antialiasing can be further improved, as it is right now, it is as if nothing is being done to antialias the images. I guess this applies to both viewer and gallery mode although it is more noticeable when viweing the small thumbnails.

@charbelnicolas
Copy link
Author

Here are the images I used for the screenshot above:

https://drive.google.com/drive/folders/1uBYhZc1STvh3qZPcyRWNxExgPBrLkpB2?usp=sharing

@artemsen
Copy link
Owner

Yes, unfortunately the current implementation of antialiasing only works well for zooming.
To be honest, I'm afraid to change it because it's not very simple and I've already forgotten what I wrote there =)

@artemsen artemsen self-assigned this Aug 29, 2024
@artemsen artemsen added the bug Something isn't working label Aug 29, 2024
@charbelnicolas
Copy link
Author

I found this website from the creator of the Magic Kernel which is supposedly what facebook and instagram use to scale their images... It even has a 2021 Reference ANSI C implementation of the Magic Kernel Sharp (MIT-0 License).

https://johncostella.com/magic/

https://johncostella.com/magic/magic-kernel-sharp.tar.gz

Maybe it is worth having a look, I really have no idea how hard it could be to implement it in swayimg

@artemsen
Copy link
Owner

artemsen commented Sep 3, 2024

Thank you!
Looks interesting but it will take a lot of time to study this code.
Image transformation is math, but I'm more of an engineer than a mathematician =)

@charbelnicolas
Copy link
Author

Hello Artem! Sorry for bothering you again. I had the chance to check the antialiasing today and unfortunately I did not notice any improvement, just the jagged edges shifting in place. I've made a comparison between feh's antialiasing and swayimg's and there is a vast difference:

feh aliased:
ss_2024_09_16_14_07_25

feh antialiased:
ss_2024_09_16_14_07_27

swayimg aliased:
ss_2024_09_16_14_07_34

swayimg antialiased:
ss_2024_09_16_14_07_36

As a matter of fact it is impossible to distinguish when antialiasing is enabled in swayimg since it doesn't really change that much.

@artemsen artemsen reopened this Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants