swhitty / SwiftDraw

Swift library and command line tool to convert SVGs into SFSymbol, PNG, PDF and Swift source code.
zlib License
326 stars 41 forks source link

Base64 encoded images are cut off #40

Closed andrewjmead closed 5 days ago

andrewjmead commented 1 month ago

Hey, Simon.

First, thanks for the library. It's been quite helpful.

I'm using SwiftDraw to render a SVGs that are user uploaded. I noticed a problem with SVGs that have base64 encoded image data embedded in them. They're getting cut off no matter how I seem to configure it.

Most SVGs work just fine. A few, this one included, get clipped. Any thoughts on this?

Thanks!

Original SVG:

icon.svg.zip

Screenshot 2024-05-20

SwiftDraw rendered version

Screenshot 2024-05-20

Demo code I'm working with:

let svgURL = URL(string: "https://ps.w.org/independent-analytics/assets/icon.svg")!
let svg = SVG(fileURL: svgURL)
let desiredSize = CGSize(width: 96, height: 96)
self.image = svg?.rasterize(with: desiredSize) // I've also tried with no "with"
swhitty commented 1 month ago

Thank you for reporting the defect @andrewjmead 🙏🏻.

It should be fixed in the latest release 0.17.0.