Skip to content

Embedded Base64 image isn’t rendered #52

@WinWurm

Description

@WinWurm

Hi, i have faced with rendering issues with some svg files. The embedded png image doesn’t rendered
Here is the file
response3

File structure look like this

<svg width="80" height="80" viewBox="0 0 80 80" fill="none" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
    <rect width="80" height="80" rx="8" fill="white"/>
    <rect x="2" y="10.7491" width="76" height="58.5017" fill="url(#pattern0_373_2050)"/>
    <defs>
        <pattern id="pattern0_373_2050" patternContentUnits="objectBoundingBox" width="1" height="1">
            <use xlink:href="#image0_373_2050" transform="scale(0.00171821 0.00223214)"/>
        </pattern>
        <image id="image0_373_2050" width="582" height="448" xlink:href="data:image/png;base64,<image data>"/>
    </defs>
</svg>

if i change file structure to more simple form (remove defs section) all renders correct

<svg width="80" height="80" viewBox="0 0 80 80" fill="none" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
    <rect width="80" height="80" rx="8" fill="white"/>
    <image  x="2" y="10.7491" width="76" height="58.5017" xlink:href="data:image/png;base64,<image data>"/>
</svg>

I don’t know exactly, but it’s looks like the issue occurs because image UIGraphicsImageRenderer initiated with svg size (defined at file beginning) and embedded image renders in more bigger rect width="582" height="448" by using CGRenderer.draw(image: CGImage, in rect: CGRect) and only after rendering its scaling

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions