-
Notifications
You must be signed in to change notification settings - Fork 165
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
SVGs with percentages for width
and height
result in inconsistent output
#933
Comments
width
and height
results in inconsistent outputwidth
and height
result in inconsistent output
width
and height
result in inconsistent outputwidth
and height
result in inconsistent output
@jseppi - looks inconsistent indeed. I'll take a look, thanks. |
@artemp what is the status of this ticket? |
I'm working to address this issue as part of mapnik/mapnik#4225 <svg xmlns='http://www.w3.org/2000/svg' width='100%' height='100%'> <!-- NOTE: no "viewBox"-->
<rect fill='#f0f' width='100%' height='100%'/>
</svg> and mapnik.Image.fromSVGBytes(svg_bytes, {width:32, height:24} , (err, image) => {
} will result in 32x24 image /cc @springmeyer @jseppi |
mapnik/mapnik@654a3c1 |
Initial implementation : https://github.com/mapnik/mapnik/tree/svg-viewport svg2png --scale-factor= 4 --width=25 --height=20 // overwrite "width" and "height" outermost `<svg>` element Resulting |
If an SVG buffer with percentage-based
width
andheight
attributes is passed tomapnik.fromSVGBytes
(or I assume any of the otherfromSVG
methods), the callback receives noerror
and a non-nullimage
result.However, the
image
result is inconsistent. If the SVG haswidth="100%" height="100%"
, we get back an image that, when encoded to PNG, is 1px x 1px.If the SVG has non-100% values, like
width="90%" height="90%"
, we get back an image, that when encoded to PNG, throws an error:Could not write to empty stream
.Desired behavior: Since it seems like percentage-based
width
andheight
values do not really produce a usable image in any case, I think the callback tofromSVGBytes
should instead receive aerror
(maybe like"svg must have pixel-based width and height values"
) andnull
result.Example test cases:
cc @artemp
The text was updated successfully, but these errors were encountered: