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

Retina images are not handled properly #338

Open
chimit opened this issue Jul 29, 2024 · 1 comment
Open

Retina images are not handled properly #338

chimit opened this issue Jul 29, 2024 · 1 comment
Labels
awaiting reply Waiting for a response from the author to proceed

Comments

@chimit
Copy link

chimit commented Jul 29, 2024

If you make a screenshot on a Retina computer (any modern Mac) and select a visible area of 200x200 px the screenshot file would be 400x400. Here is an example file:

image_400x400

Most of the browsers display such images as is - with the resolution of 400x400 (try to open this image in a new tab). So such images look twice as large from the original visible size. But it's possible to detect high density image, e.g. the screenshot above looks good because Github set 200px width, not 400px. But unlike Github, Astro when optimizing images doesn't take high density into account and doesn't reduce the value of the width attribute of the images. Is it possible to fix it?

@satnaing
Copy link
Owner

At the time of writing this, you can achieve the true size of the image by using <img /> tag with width attribute.

<img src="/your-image-inside-public-dir.png" width="200" height="200" alt="test">

We can use Astro's <Image /> component to achieve the desired result.
However, to use <Image /> component, we need to integrate mdx.

@satnaing satnaing added the awaiting reply Waiting for a response from the author to proceed label Aug 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting reply Waiting for a response from the author to proceed
Projects
None yet
Development

No branches or pull requests

2 participants