-
Notifications
You must be signed in to change notification settings - Fork 213
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
Low image quality when downscaling #653
Comments
resvg does use bicubic scaling, but I guess something goes wrong. Will see. |
I also tried explicitly passing |
@romanzes It most definitely is. |
Any updates on this issue? |
It will be done when it will be done. |
modify the |
I don't think this is the case. It works fine in Skia, meaning the bug is somewhere else. |
Actually, Skia has the same problem, embedded rasters look aliased when downscaled. I was able to fix it in my fork of Skia by changing this line to: ctx.canvas()->drawImageRect(
imgInfo.fImage, imgInfo.fDst, SkSamplingOptions(SkFilterMode::kLinear, SkMipmapMode::kLinear)); However, as far as I understand, |
@romanzes That's surprising. I will double check later. If Skia fails in the same way as tiny-skia then there is nothing we can do, sort of. We would have to find a workaround. And no, tiny-skia doesn't support mipmapping. Afaik it was a lot of work to implement and Skia uses some sort of shared cashing for them. Too much complexity for now. |
The use case is a PNG image which is base64-encoded and embedded in the SVG in an
<image>
tag. In the attached example, the original image is 160x160, and scaled down to 49x49 in the SVG markup.The rendered image (resvg-rendered-49px.png) quality is degraded, especially on the curves.
When defining the dimensions as 160x160 in the SVG markup, the rendered image (resvg-rendered-160px.png) quality is great. And when including that image on an HTML page and re-scaling in the HTML markup,
<img src="resvg-rendered-160px.png" width="49" height="49">
, the image quality remains crisp.We also tried setting the
image-rendering
attribute forOptimizeQuality
, but the improvement was negligible.https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/image-rendering
Is is correct that Bicubic interpolation is being used? Do you have any guidance for improving image quality, and/or are there plans for other interpolation options?
Processing this same image with various interpolation filters in
ImageSharp
(e.g. Lanczos, MitchellNetravali, etc.) does produce a high quality result.The text was updated successfully, but these errors were encountered: