SDWebImage / SDWebImageSVGCoder

A SVG coder plugin for SDWebImage, using Apple's built-in framework
MIT License
103 stars 34 forks source link

Wrong rendering of minified SVG files in iOS15 and below #49

Open dhidalgofadrique opened 10 months ago

dhidalgofadrique commented 10 months ago

I'm facing an issue rendering some SVG images which are minified in iOS15 and below, that is, some spaces are removed inside the path to reduce svg size. In those cases (minified ones) the image is rendered missing some paths. It can be checked using these two images:

Minified Normal
minifiedVersion normalVersion

As you can see the "+" is not rendered in the minified version:

NormalMinified

As far as I've could investigate the problem occurs in the arc paths (the ones starting with a) in which this format:

a.689.689 0 0 1 0 1.377

is replaced by this one:

a.689.689 0 010 1.377

Both images are shown correctly in any SVG viewer. Anyone facing this issue too?

Thanks!

dreampiggy commented 10 months ago

...Seems CoreSVG behavior differences ? Can you use the Adobe svg-native coder for testing as well ?

https://github.com/SDWebImage/SDWebImageSVGNativeCoder

dhidalgofadrique commented 10 months ago

With this coder the image seems ok but we need the SVG version 😔 due to the image looses a lot of quality

Captura de pantalla 2023-10-25 a las 8 53 08
dreampiggy commented 10 months ago

@dhidalgofadrique SVGNative coder, does not preserve vector format actually. Because only the SPI which use CoreSVG can behave as vector (See readme)

For SVGNaive coder, however, you can, provide a context option .imageThumbnailPixelSize: CGSize(width: 1000, height: 1000)

Which draw a big enough bitmap version of SVG. So it still looks sharp.

dreampiggy commented 10 months ago

See: https://github.com/SDWebImage/SDWebImageSVGNativeCoder#render-svg-as-bitmap-image