androidsvg icon indicating copy to clipboard operation
androidsvg copied to clipboard

<image> tag with only width will not render

Open TangoBloom opened this issue 4 years ago • 4 comments

When rendering on the web, if I have a CSV with an image tag that only has the width set, the height will fill according to aspect ratio. When using the androidSVG library, the will simply not display at all.

example: <image id="photo" xlink:href="data:image/png;base64,someimage" width="107" y="11.5" x="12" clip-path="url(#clip)"/>

TangoBloom avatar Aug 26 '21 17:08 TangoBloom

Currently AndroidSVG only officially supports SVG 1.1. In that version of SVG, width or height will default to 0 when not specified. And, per the spec, a value of 0 disabled rendering.

In SVG 2, which the browsers support most of now, width and height default to auto. In SVG terms that equates to "100%". That's why you are seeing different behaviour in the browser, compared with AndroidSVG.

I will gradually be implementing SVG2 spec features. So I will mark this issue as a feature request for the new SVG2 geometry attribute behaviour.

Thanks for the report.

BigBadaboom avatar Aug 27 '21 04:08 BigBadaboom

Hey great, thanks for the quick response!

So would I be able to put "100%" for height and have that render properly?

TangoBloom avatar Aug 27 '21 04:08 TangoBloom

Yes. Setting height to "100%" should have the same effect.

BigBadaboom avatar Aug 27 '21 04:08 BigBadaboom

Lovely. Thank you for the library!

TangoBloom avatar Aug 27 '21 04:08 TangoBloom