Skip to content

Rasterized SVG is empty #49

Closed
Closed
@gnrcampos

Description

@gnrcampos

First of all thanks for the great library you put together, it's been really useful for me so far. Having said that, I'm having a hard time with a particular asset which is pasted below.
My code looks like:

let svg = SVG(fileURL: assetURL)
let insets = UIEdgeInsets(top: 0, left: -1, bottom: 0, right: -1)
let size = CGSize(width: 238, height: 240)
let image = svg.rasterize(with: size, insets: insets)

The resulting UIImage is empty. I use the same code with other SVG images and it works fine which makes me think it's something to do with the way this particular asset was created.
Here's the SVG data:

<?xml version="1.0" encoding="UTF-8"?><svg id="Images" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 595.43 600"><defs><style>.cls-1{fill:url(#_Áåçûìÿííûé_ãðàäèåíò_823);}</style><linearGradient id="_Áåçûìÿííûé_ãðàäèåíò_823" x1="297.71" y1="590" x2="297.71" y2="10" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#caeca6"/><stop offset=".15" stop-color="#d4e2b6"/><stop offset=".46" stop-color="#eecae2"/><stop offset=".63" stop-color="#fbf"/><stop offset=".7" stop-color="#fab8ff"/><stop offset=".79" stop-color="#ecb0ff"/><stop offset=".88" stop-color="#d6a3ff"/><stop offset=".97" stop-color="#b692ff"/><stop offset="1" stop-color="#aa8bff"/></linearGradient></defs><g id="_01"><path class="cls-1" d="m473.23,38.41l5.11,66.12c1.03,13.27,9.45,23.63,22.06,27.14l62.84,17.49c36,10.02,25.93,63.79-13.83,73.81l-69.4,17.49c-13.93,3.51-26.23,13.87-32.22,27.14l-29.88,66.12c-17.12,37.88-70.88,37.88-73.81,0l-5.11-66.12c-1.02-13.27-9.45-23.63-22.06-27.14l-62.84-17.49c-36-10.02-25.93-63.79,13.83-73.81l69.4-17.49c13.93-3.51,26.23-13.87,32.22-27.14l29.88-66.12c17.12-37.88,70.88-37.88,73.81,0ZM132.59,353.1l-21.87,48.39c-4.39,9.71-13.39,17.29-23.58,19.86l-50.79,12.8c-29.09,7.33-36.46,46.68-10.12,54.01l45.99,12.8c9.23,2.57,15.39,10.15,16.14,19.86l3.74,48.39c2.14,27.72,41.49,27.72,54.01,0l21.87-48.39c4.39-9.71,13.39-17.29,23.58-19.86l50.78-12.8c29.09-7.33,36.46-46.68,10.12-54.01l-45.99-12.8c-9.23-2.57-15.39-10.15-16.14-19.86l-3.74-48.39c-2.14-27.72-41.49-27.72-54.01,0Z"/></g></svg>

The asset is rendered correctly on Edge, Chrome, Preview, and it works when I use SVGView to render it, but I need to extract a CGImage at another point in my application that makes using SVGView not an option.
Thanks in advance!

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