SDWebImageSVGCoder
SDWebImageSVGCoder copied to clipboard
Wrong rendering of minified SVG files in iOS15 and below
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 |
|---|---|
As you can see the "+" is not rendered in the minified version:
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!
...Seems CoreSVG behavior differences ? Can you use the Adobe svg-native coder for testing as well ?
https://github.com/SDWebImage/SDWebImageSVGNativeCoder
With this coder the image seems ok but we need the SVG version 😔 due to the image looses a lot of quality
@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.
See: https://github.com/SDWebImage/SDWebImageSVGNativeCoder#render-svg-as-bitmap-image