SDWebImageSVGCoder icon indicating copy to clipboard operation
SDWebImageSVGCoder copied to clipboard

Wrong rendering of minified SVG files in iOS15 and below

Open dhidalgofadrique opened this issue 2 years ago • 4 comments

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!

dhidalgofadrique avatar Oct 24 '23 15:10 dhidalgofadrique

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

https://github.com/SDWebImage/SDWebImageSVGNativeCoder

dreampiggy avatar Oct 25 '23 06:10 dreampiggy

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

dhidalgofadrique avatar Oct 25 '23 06:10 dhidalgofadrique

@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 avatar Oct 26 '23 04:10 dreampiggy

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

dreampiggy avatar Oct 26 '23 04:10 dreampiggy