SDWebImage / SDWebImageSVGCoder

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

Small SVG renders blurry on watchOS #27

Closed Maxador closed 3 years ago

Maxador commented 3 years ago

If I try to render an SVG with a bigger size than the SVG file is setting, the image will render blurry. I tried to use the solution proposed in https://github.com/SDWebImage/SDWebImageSVGCoder/issues/24 but without success. I had it kinda working by setting values to my CGSize like this [.imageThumbnailPixelSize : CGSize(width: 34, height: 34)] but unfortunately not all my images are square and I don't want to constraint the width.

SwiftUI Rendering code

WebImage(url: imageURL), context: [.imageThumbnailPixelSize : CGSize.zero])
            .renderingMode(.template)
            .resizable()
            .placeholder(Image(systemName: "photo"))
            .scaledToFit()
            .frame(height: 34)
            .padding(.bottom, 6)
CGSize.zero CGSize(width: 34, height: 34)
Simulator Screen Shot - Apple Watch Series 6 - 44mm - 2020-12-11 at 09 28 24 Simulator Screen Shot - Apple Watch Series 6 - 44mm - 2020-12-11 at 09 30 20

Is there a way to render the bitmap to a certain height without requesting a width while keeping the aspect ratio of the image?

dreampiggy commented 3 years ago

Is there a way to render the bitmap to a certain height without requesting a width while keeping the aspect ratio of the image?

Sounds like a new feature request. Can't you pre-calculate the size of length and disable the aspect ratio ?

If you can't, we have to provide some new options, or even like a calculation size block closure for advanced use case.