Skip to content

SVG: read the width and height auto of an <image> like missing ones - #2183

Open
RavSinghChandan wants to merge 3 commits into
py-pdf:masterfrom
RavSinghChandan:svg-image-size-auto
Open

RavSinghChandan wants to merge 3 commits into
py-pdf:masterfrom
RavSinghChandan:svg-image-size-auto

Conversation

@RavSinghChandan

Copy link
Copy Markdown

<image width="auto" height="30" href="..."> fails with ValueError: Unable to parse 'auto' as a length.

In SVG 2, auto is the initial value of an <image>'s width and height: the size of the image itself, or the one that keeps its ratio with the other side. That is what a missing width or height already gives, as 0, through size_in_document_units(), so build_image() now reads auto like a missing size.

test_svg_image_size_auto covers auto for each side, both sides, uppercase and padded with spaces; it fails without the change.

<image width="auto"> failed with ValueError: Unable to parse 'auto' as a
length. auto, the initial value in SVG 2, is the size of the image
itself, which a missing width or height (0) already gives through
size_in_document_units().
# Conflicts:
#	CHANGELOG.md
# Conflicts:
#	CHANGELOG.md

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant