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

Scaled down images look excessively pixelated on desktop #2883

Open
hypergonial opened this issue Mar 9, 2025 · 2 comments
Open

Scaled down images look excessively pixelated on desktop #2883

hypergonial opened this issue Mar 9, 2025 · 2 comments
Labels
help wanted Issues that are up for grabs + are good candidates for community PRs

Comments

@hypergonial
Copy link

hypergonial commented Mar 9, 2025

Describe the bug

Large AsyncImages scaled down (compared to their original size) look excessively pixelated (on at least) desktop. This doesn't seem to be an issue on Android, so I'm guessing this is not intended behaviour? I can only test these two platforms right now, so it is possible other platforms are also affected.

The effect is most noticeable with screenshots that contain lots of text, as the text becomes completely distorted and unreadable.

To Reproduce

Try to load a high-resolution image with medium-to-small text on it, as the issue is most apparent on images of this type, (e.g. a screenshot of an IDE window) and try to scale it down.

Version
v3.1.0

Samples

Original image:

Image

Android scaled down a lot (this is still just about readable!):

Image

Desktop scaled down slightly (already falling apart):

Image

Desktop scaled down a lot (unreadable):

Image

I considered that this is simply due to the higher pixel density of a phone's screen, but the issue is also not reproducible in the emulator so I'm not sure anymore. 😅

@ojasvib
Copy link

ojasvib commented Mar 10, 2025

Can you share the exact code you are using to scale the images down, it might be helpful for figuring out why this is happening.

@hypergonial
Copy link
Author

hypergonial commented Mar 10, 2025

Can you share the exact code you are using to scale the images down, it might be helpful for figuring out why this is happening.

Hi!

As far as I can tell, the only thing coil-related is ContentScale.Fit.

AsyncImage(
    model = ImageRequest.Builder(LocalPlatformContext.current).data(url).crossfade(true).build(),
    contentDescription = attachment.filename,
    modifier =
        Modifier.padding(top = 8.dp, end = 20.dp)
            .widthIn(Dp.Unspecified, 500.dp)
            .heightIn(Dp.Unspecified, 500.dp)
            .clip(RoundedCornerShape(8.dp))
            .clickable(null, indication = null) { component.onAttachmentClicked(attachment.id) }
            .pointerHoverIcon(PointerIcon.Hand),
    contentScale = ContentScale.Fit,
)

The ImageLoader is defined as follows:

setSingletonImageLoaderFactory { context ->
    ImageLoader.Builder(context).crossfade(true).build()
}

The project I'm working on is open source, with this snippet originating from here, if that's of any use.

@colinrtwhite colinrtwhite added the help wanted Issues that are up for grabs + are good candidates for community PRs label Mar 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Issues that are up for grabs + are good candidates for community PRs
Projects
None yet
Development

No branches or pull requests

3 participants