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

App icons are blurry with 200% scaling #3176

Open
PhilippSua opened this issue May 10, 2024 · 12 comments
Open

App icons are blurry with 200% scaling #3176

PhilippSua opened this issue May 10, 2024 · 12 comments

Comments

@PhilippSua
Copy link

App icons are blurry with 200% scaling:

grafik

The icon used here (https://dl.flathub.org/media/org/gnome/gitlab.somas.Apostrophe/79e84cd62f433972088419e196bc13ff/icons/128x128/org.gnome.gitlab.somas.Apostrophe.png) is 128x128px and probably scaled up to 256x256px. In the requirements for application icons either .svg or a .png with at least 256x256px is defined. The original icon of Apostrophe from the screenshot for example is provided as a .svg. Is flathub creating the png version used on the website and only generates 128x128px files?

@razzeee
Copy link
Member

razzeee commented May 10, 2024

Yes that's here https://dl.flathub.org/media/org/gnome/gitlab.somas.Apostrophe/79e84cd62f433972088419e196bc13ff/icons/128x128@2/org.gnome.gitlab.somas.Apostrophe.png

But you can always zoom in deep enough, to make it blurry - not much we can do here.

@PhilippSua
Copy link
Author

I'm not zooming to 200% with my browser. I have 200% scaling enabled in GNOME because I have a HiDPI screen. I'm not asking flathub to support an arbitary high resolution for icons here. But if you use 128x128 px icons on the website you should provide 256 x 256 px icons for HiDPI screens too. Otherwise Flathub looks blurry for everyone with a modern HiDPI screen like for example 2880x1800 14-inch laptops.

App icons appear blurry in GNOME Software too on HiDPI screens: https://gitlab.gnome.org/GNOME/gnome-software/-/issues/2559

@razzeee
Copy link
Member

razzeee commented May 10, 2024

Blocked on #1453 then as this would bog down smaller screens / bad connections otherwise

@PhilippSua
Copy link
Author

Blocked on #1453 then as this would bog down smaller screens / bad connections otherwise

I think a CDN as mentioned in #1453 might not be needed to accomplish using different PNGs at different integer scale levels. PNG are already available for 2x integer scale and most up to date browsers should support the scrset attribute (https://caniuse.com/srcset). I assume something like the following should work:

<img src="/images/mylogo-default.png"
  srcset="/images/mylogo-density1.png 1x, /images/mylogo-density2.png 2x">

img src defines the default png used when the browser doesn't support the srcset attribute.
srcset prpvides two variants for standard (1x) and double (2x) pixel density.

See: https://www.nginx.com/blog/responsive-images-without-headaches-nginx-plus/#element-attrdef-img-srcset

@PhilippSua
Copy link
Author

I have tested my approach by manually editing the html of Flathub's website using the Firefox developer tools like this:

<img alt="Biblioteca Logo" aria-hidden="true" loading="lazy" width="128" height="128" decoding="async" data-nimg="1" style="color: transparent; max-width: 100%;" src="https://dl.flathub.org/media/app/drey/Biblioteca/0ddd95726933bb60f74ca1fd63c3de78/icons/128x128/app.drey.Biblioteca.png"
srcset="https://dl.flathub.org/media/app/drey/Biblioteca/0ddd95726933bb60f74ca1fd63c3de78/icons/128x128/app.drey.Biblioteca.png) 1x, https://dl.flathub.org/media/app/drey/Biblioteca/0ddd95726933bb60f74ca1fd63c3de78/icons/128x128@2/app.drey.Biblioteca.png 2x">

It works :)

@razzeee
Copy link
Member

razzeee commented May 13, 2024

I've added the Icons array some time ago on this endpoint https://flathub.org/api/v2/appstream/app.drey.Biblioteca

You can use it to get the correct icon paths, but it might be empty

@PhilippSua
Copy link
Author

You can use it to get the correct icon paths, but it might be empty

Why can they be empty? Are the icons and specifically 128x128@2 not automatically created by the Flathub CI?

@razzeee
Copy link
Member

razzeee commented May 13, 2024

No, they are only generated if the app has a scalable svg (or maybe if they provide a big enough png) and if they have been rebuild since we switched to libappstream

@PhilippSua
Copy link
Author

Is it possible to check the availability of the @2 icons somehow and fall back to the default icon if it's not available?

@PhilippSua
Copy link
Author

There is https://gitlab.gnome.org/GNOME/gnome-software/-/issues/2559 tracking the corresponding issue about blurry icons in GNOME Software.

@razzeee
Copy link
Member

razzeee commented May 15, 2024

Is it possible to check the availability of the @2 icons somehow and fall back to the default icon if it's not available?

You can do that via the Icons array.

@razzeee
Copy link
Member

razzeee commented May 21, 2024

Trying to use srcset via nextjs seems broken for our use case

vercel/next.js#27547

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