#poor image quality on firefox
44 messages · Page 1 of 1 (latest)
Are the files actual svg files? You can open them and see the svg element etc?
ofc they are
yeh yeh
Are you loading them with the Image component?
no
it's inside tsx file not astro
Are you using any kind of component or image optimization? or just a standard img tag?
just img
I can share the link if you want to inspect it, but not here. I can DM it only
If you can share some code or a minimal reproduction here that would be helpful for finding a resolution
It's generally discouraged to provide support via DMs because less eyes get working on the problem and it's no longer catalogued here for future users with similar issues
actually, it's a project website and has not been released yet. I can't share it without the consent of the company. Let me try to provide something that can help
Minimal reproduction would probably be your best bet then
I just reproduced the same thing I am using in my main project. Here it is: https://testastroimage.vercel.app
Great 😄
The code would be helpful though 🙂
here it is:
index.astro
import Test from "../components/test.tsx"
---
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width" />
<meta name="generator" content={Astro.generator} />
<title>Astro</title>
</head>
<body>
<Test />
</body>
</html>
/components/test.tsx
import sectigo from "../_images/sectigo.svg";
import geotrust from "../_images/geotrust.svg";
import thawte from "../_images/thawte.svg";
import rapidssl from "../_images/rapidssl.svg";
import gogetssl from "../_images/gogetssl.svg";
export default function Test() {
return (
<div className="flex w-full flex-col items-center bg-card">
<div className="flex max-w-screen-lg flex-col justify-center gap-2 py-5 lg:flex-row">
<img
src={gogetssl.src}
alt="rapidssl"
width={150}
className="w-full max-w-screen-sm lg:w-[150px]"
/>
<img
src={digicert.src}
alt="digicert"
width={150}
className="w-full max-w-screen-sm lg:w-[150px]"
/>
<img
src={sectigo.src}
alt="sectigo"
width={150}
className="w-full max-w-screen-sm lg:w-[150px]"
/>
<img
src={geotrust.src}
alt="geotrust"
width={150}
className="w-full max-w-screen-sm lg:w-[150px]"
/>
<img
src={thawte.src}
alt="thawte"
width={150}
className="w-full max-w-screen-sm lg:w-[150px]"
/>
<img
src={rapidssl.src}
alt="rapidssl"
width={150}
className="w-full max-w-screen-sm lg:w-[150px]"
/>
</div>
</div>
);
}
Where are you storing you're images?
It seems like they are in the src directory which is causing them to be bundled and processed by astro.
Might be able to alleviate those issues by storing them in public since you are using the default img element anyway
Then reference them like src="/gogetssl.svg" without directly importing them into the file
Also try
import gogetssl from "../_images/gogetssl.svg?url";
yeh they are under
src/_images
try putting them in public or public/images and then reference them like i described above in the src (with the correct path of course)
I tried the public folder method and also changed the code you provided, but it doesn't seem to be working
btw, i am only facing this issue with the firefox browser
its alright in edge, chrome and brave
Yeah I saw it in chrome and it was fine
I did a small amount of research and you are apparently not the first to run into issues like that in firefox, it may be something to do with the size of the SVGs
I didn't follow that path to deeply but might be worth looking into
cc <@&1129102257422610512>
I think I've reached the extent of my knowledge on this, looking for some backup ❤️
theres one more fix
and from a more recent one
request an image size larger than what you need, resize it via style after
the cost is SLIGHTLY larger images but 10x the quality
I recommend using astro-icon instead of <img>. It will optimize and inline your SVGs. It also avoids duplicate bloat.
https://www.astroicon.dev/
not sure it'll address your issue, but you will get better performance.
I agree with the recommendation! Didn't mention it myself because I was also unsure if it would resolve anything, but hey performance gains are performance gains
so to be clear the link I put is for when using astro:image
i recommend using that
Astro image component doesn’t actually do anything to SVGs I’m guessing this issue isn’t actually related to Astro since they’re just image tags with an svg src but it is possible that it’s something weird Astro / the react renderer is doing
Using actual SVGs will definitely get the best quality
But this is a bizarre issue it could be interesting to drill into
I could to test we should try it without react involved
it could also be worth searching if anyone else has had issues with svgs in img tags on Firefox
The OP is using <img> not the <Image /> component, that was Lloyd's suggestion
Yeah the <Image /> component will just make <img> tags it doesn’t actually optimize the svgs
Exactly. That's why I use astro-icon instead.
these arent icons though, they are logos
It's just a package name, there's nothing about it preventing it from being used with other svgs to my knowledge