-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
SVG rendering seems incorrect. #301
Comments
Hi Izaak, The mostly-white output with the blue bar at the top looks like (un)premultiply gone wrong - I suspect *magick is reporting the SVG as having an alpha channel but then not supplying the right values. The green and red output looks like a colourspace conversion gone wrong, perhaps as a cumulative effect of an incorrect alpha channel. What does There are known (but probably unrelated) density/resolution problems when using SVG - see #110. |
sharp-loader looks similar to https://github.com/papandreou/express-processimage wrt. the features and the supported syntax. I'm glad that others are picking up the same idea as having such an image processing pipeline is very powerful. For express-processimage we gave up on imagemagick/graphicsmagick's lacklustre SVG support and used inkscape instead via https://github.com/papandreou/node-inkscape |
@lovell thanks for the fast reply! Here is the metadata output:
And yes, the example SVG you linked is the one I used to create the above raster images. |
It seems weird that |
@papandreou cool! Trying to keep the number of external program/library dependencies down... people have a hard enough time installing native libs as it is it seems... But if this doesn't work out then I'll certainly explore that! |
I think this problem relates to sharp's use of |
Great 😄 Let me know if you need me to test anything! |
Thanks @izaakschroeder. This problem affects sharp when used with libvips 8.1.0+ (as sharp uses the new There is a test for SVG to PNG but unluckily it's one of the few remaining scenarios that is not fully automated and I hadn't spotted the broken output. I'll automate the test before fixing the bug! |
Woohoo thanks @lovell! |
Improves SVG support as *magick serves these as 16-bit Add automated tests for SVG and 16-bit+alpha PNG inputs
Commit 05dd191 on the npm install lovell/sharp#look |
The npm install lovell/sharp |
Testing... and I get:
😄 |
Maybe it needs: #include <cmath> ^ @lovell |
Yes, sorry, I forgot to add that to keep clang happy - please try now. |
Does this mean Thanks again for all the fantastic work on this! 🎉 |
Thanks Izaak for confirming this solves the problem and for reporting it in the first place. v0.12.0 should be published within the next few days. |
I have attempted to write a webpack loader for the glorious sharp. It is available here: https://github.com/izaakschroeder/sharp-loader. It's supposed to expose most of sharp to webpack to do things like create 1x,2x,3x versions of assets or webp for chrome and so on. The bug I'm dealing with right now is just about SVG though.
Sometimes original assets are present in SVG and PNG is needed for browsers that don't support SVG (cough old satanic versions of IE).
In the spirit of that, using the aforementioned loader to do something like:
Should generate a sensible image (and indeed
vips pngsave visa.svg visa.png
produces something sane). Sadly,sharp
appears to produce unintelligible gibberish when it comes to SVGs 😢^ Generated via
vips
command-line.^ Generated via
sharp
.^ Generated via
sharp
withflatten()
applied first.Not quite sure what's going on here, but some general direction to troubleshooting this would be super appreciated 😄
The results come from running this example: https://github.com/izaakschroeder/sharp-loader/tree/master/example and should be reproducible by something like:
The text was updated successfully, but these errors were encountered: