Hi!
How I can use SDImageCache to cache SVG image?
Is it real to use SDWebImage to download SVG? Now I use another library but I need to cache SVG-image.
Thank you.
any update the same here ?
svg images are not supported yet
Any updates on this one?
No updates - I don't think anyone is working on this
Look at some dedicated SVG lib, like SVGKit.
You can use SVGKit to create a custom decoder, and then you can add that coder to SDWebImageCodersManager. Then just start using, really easy.
To know how to build a custom coder, see Custom Coder
any update?
@SergeyDevUA @sashkasashkin Since we have the coder plugins, it's not hard to write one by yourself. The protocol is not hard to implement.
But anyway, if you still prefer to use a out-of-box SVG support. I can spend little time to write one by using third-party library support.
At first, I suggest to use SVGKit to build the coder plugin because when I search github, it contains the most stars. However, after I run the demo project and found that this repo is really ancient. And it contains bug don't render alpha-channel SVG well. So I'm hesitated to use this framework.
Then I found that there is one repo SwiftSVG with more than 1000 stars. I will try that. Note since this is s Swift framework, user who only use Objective-C code should use the Swift-Objective-C bridging way, this may increase their binary size because of Swift's runtime library.
UPDATE
After I create another demo code, I found that SwiftSVG is buggy as well. When using the official demo code to render this SVG: https://upload.wikimedia.org/wikipedia/commons/1/14/Mahuri.svg, the application die and result a 100% CPU nearlly 10 seconds. I don't think it's good enough for production. 馃槬
So let me try some other choice, or I can firstly show your demo framework using SVGKit. At least it will not die when loading complicated SVG files.
@SergeyDevUA @sashkasashkin I create one simple wrapper framework SDWebImageSVGCoder using SVGKit, please have a try and provide some feedback. The Podfile may looks like this
pod 'SDWebImageSVGCoder`, :git => 'https://github.com/dreampiggy/SDWebImageSVGCoder.git', :branch => 'master'
pod 'SVGKit', :git => 'https://github.com/SVGKit/SVGKit.git', :branch => '2.x'
If you still want to use SwiftSVG this library for actual SVG parsing, you can also try this one SDWebImageSVGCoder-Swift. But during my test, this one performance is really bad for some complicated SVG images. Use with cautious.
@SergeyDevUA @sashkasashkin Any feedback ?
Currently that SDWebImageSVGCoder only decode the SVG images to the bitmap image (fixed size), it's not a vector format to allow you to resize it into any size without losing the detail.
If you use the SVGKFastImageView or SVGKLayeredImageView to support vector images and resizing, maybe I can also update to provide a demo.
I add support for SVGKImageView, yoiu can check the SDWebImageSVGCoder Usage and run the demo.
SVGKImageView *imageView; // can be either `SVGKLayeredImageView` or `SVGKFastImageView`
imageView.contentMode = UIViewContentModeScaleAspectFill;
imageView.sd_adjustContentMode = YES; // make `contentMode` works
[imageView sd_setImageWithURL:url];
iOS support pdf vector image!!
@satishVekariya
See https://github.com/SDWebImage/SDWebImagePDFCoder
Most helpful comment
SVGKit
@SergeyDevUA @sashkasashkin I create one simple wrapper framework SDWebImageSVGCoder using SVGKit, please have a try and provide some feedback. The
Podfilemay looks like thisSwiftSVG
If you still want to use SwiftSVG this library for actual SVG parsing, you can also try this one SDWebImageSVGCoder-Swift. But during my test, this one performance is really bad for some complicated SVG images. Use with cautious.