SDWebImageWebPCoder icon indicating copy to clipboard operation
SDWebImageWebPCoder copied to clipboard

A WebP coder plugin for SDWebImage, use libwebp

Results 13 SDWebImageWebPCoder issues
Sort by recently updated
recently updated
newest added

Possible logic error in scaling ('encodeMaxPixelSize' option)

[{"_id":"63542e93ea01ec786e77a30a","body":"This logic seems wrong...\r\n\r\nIn general, this should works as aspect fit scale down, not aspect fill. So you're correct.\r\n\r\nI'll fix today with new patch version :)","issue_id":1660696641833,"origin_id":1159933886,"user_origin_id":6919743,"create_time":1655696450,"update_time":1655697027,"id":1666461331096,"updated_at":"2022-10-22T17:55:31.095000Z","created_at":"2022-10-22T17:55:31.095000Z"},{"_id":"63542e93ea01ec786e77a30b","body":"Need to fix SDWebImage Core logic as well...\r\n\r\nhttps:\/\/github.com\/SDWebImage\/SDWebImage\/blob\/5.12.6\/SDWebImage\/Core\/SDImageIOCoder.m#L255\r\n\r\nActually I can adjust this condition into a function to make its behavior matches across the libraries.","issue_id":1660696641833,"origin_id":1159938235,"user_origin_id":6919743,"create_time":1655697141,"update_time":1655697141,"id":1666461331099,"updated_at":"2022-10-22T17:55:31.099000Z","created_at":"2022-10-22T17:55:31.099000Z"},{"_id":"63542e93ea01ec786e77a30c","body":"Fixed in v0.8.5 and v0.9.0","issue_id":1660696641833,"origin_id":1241824506,"user_origin_id":6919743,"create_time":1662721040,"update_time":1662721040,"id":1666461331102,"updated_at":"2022-10-22T17:55:31.101000Z","created_at":"2022-10-22T17:55:31.101000Z"}] comment

Hi! I'm using **SDWebImageWebPCoder** to convert my images to WEBP and have stumbled upon what looks like a logic error in scaling with `encodeMaxPixelSize` option. The case looks like this:...

It would be good to have an option to skip frames for animated webP. If I have a thumbnail trying to render an animated wepb image with 120 frames it...

enhancement

Carthage build fails when using XCFrameworks flag

[{"_id":"6354232a8041c95dfb11dccd","body":"That #57 merged. I'll release a patch version 0.8.4\r\n\r\nHowever, is this only thing to do that support Carthage with XCFramework ?\r\n\r\nI remember the issue talked here: https:\/\/github.com\/Carthage\/Carthage\/issues\/3019#issuecomment-786350898\r\n\r\nCarthage need all the downstream component, to update their Xcode and create a new scheme \"Like SDWebImage XCFramework\" and add dependency to that. ","issue_id":1660696641843,"origin_id":833340580,"user_origin_id":6919743,"create_time":1620289962,"update_time":1620289991,"id":1666458410881,"updated_at":"2022-10-22T17:06:50.880000Z","created_at":"2022-10-22T17:06:50.880000Z"},{"_id":"6354232a8041c95dfb11dcce","body":"This is not the case in my experience. For example, SDWebImage and other dependencies build fine as XCFrameworks already.\r\n\r\n![SDWebImageWebPCoder build console](https:\/\/user-images.githubusercontent.com\/1727803\/117303949-3b8feb80-ae4b-11eb-88f2-b6caf630e19e.png)\r\n","issue_id":1660696641843,"origin_id":833513002,"user_origin_id":1727803,"create_time":1620306866,"update_time":1620306866,"id":1666458410888,"updated_at":"2022-10-22T17:06:50.888000Z","created_at":"2022-10-22T17:06:50.888000Z"},{"_id":"6354232a8041c95dfb11dccf","body":"Looks great. If Carthage's XCFramework adoptation does not cost too much of maintainess issues, I can update all [SDWebImage related components](https:\/\/github.com\/SDWebImage) together.","issue_id":1660696641843,"origin_id":834190042,"user_origin_id":6919743,"create_time":1620377998,"update_time":1620377998,"id":1666458410891,"updated_at":"2022-10-22T17:06:50.890000Z","created_at":"2022-10-22T17:06:50.890000Z"}] comment

Attempting to build SDWebImageWebPCode with Carthage using the `--use-xcframeworks` flag results in a build failure. The following error is observed in the log: ``` ...SDImageWebPCoder.h:12:9: fatal error: module 'SDWebImage' not...

Memory leaks in webp render process

[{"_id":"635421f18041c95dfb11db68","body":"@dreampiggy hi. Have you found a time to take a look on that?","issue_id":1660696641847,"origin_id":732940014,"user_origin_id":1101646,"create_time":1606220475,"update_time":1606220475,"id":1666458097814,"updated_at":"2022-10-22T17:01:37.814000Z","created_at":"2022-10-22T17:01:37.814000Z"},{"_id":"635421f18041c95dfb11db69","body":"Does this issue still exist ?\r\n\r\nI doubt `Memory Leak` you described here. The image RAM usage follows the fomula:\r\n\r\n```width * height * bytesPerPixel (4 for normal alpha RGBA8888 image)```\r\n\r\nSo, if there is one image with 2000x2000 pixels, it must allocate 15.2587890625 MB.\r\nFor 8000x8000 pixels, need 240MB.","issue_id":1660696641847,"origin_id":781890144,"user_origin_id":6919743,"create_time":1613719742,"update_time":1613720199,"id":1666458097819,"updated_at":"2022-10-22T17:01:37.819000Z","created_at":"2022-10-22T17:01:37.819000Z"},{"_id":"635421f18041c95dfb11db6a","body":"yes for iOS 12 & 13. in my case all images have a size 1080x835. So the expected memory usage should be ((1080*835*4)\/1024)\/1024=3.44009399414 per image. In my mind the image should not be rendered in case when it is not visible.\r\nSo, I can't imagine how it possible to see memory usage over 500mb (because about 145 images should be rendered).\r\n\r\nfor now I can't use webp for ios because of lelaks for old OS versions. So, I use the same set of images but jpeg, and app memory usage about 70-80mb.","issue_id":1660696641847,"origin_id":781930934,"user_origin_id":1101646,"create_time":1613724721,"update_time":1613724721,"id":1666458097822,"updated_at":"2022-10-22T17:01:37.821000Z","created_at":"2022-10-22T17:01:37.821000Z"},{"_id":"635421f18041c95dfb11db6b","body":"it can decode even animated images (webp). \r\nConsider 80 frames for that amount and it will have a `memory leak`.","issue_id":1660696641847,"origin_id":781930952,"user_origin_id":6886116,"create_time":1613724724,"update_time":1613724724,"id":1666458097826,"updated_at":"2022-10-22T17:01:37.825000Z","created_at":"2022-10-22T17:01:37.825000Z"},{"_id":"635421f18041c95dfb11db6c","body":"> yes for iOS 12 & 13. in my case all images have a size 1080x835. So the expected memory usage should be ((1080_835_4)\/1024)\/1024=3.44009399414 per image. In my mind the image should not be rendered in case when it is not visible.\r\n> So, I can't imagine how it possible to see memory usage over 500mb (because about 145 images should be rendered).\r\n> \r\n> for now I can't use webp for ios because of lelaks for old OS versions. So, I use the same set of images but jpeg, and app memory usage about 70-80mb.\r\n\r\nApple's JPEG\/GIF codec use some trick to avoid peak memory usage. It's tied Image\/IO codec and UIKit render engine.\r\n\r\nHowever, libwebp is outside of ImageIO, so once the image is not visible, UIImageView (iOS's rendering component) can not get the context to release the frame buffer.\r\n\r\nIf you use Static WebP mostlly. Using iOS 14's built-in support for WebP is better.\r\n\r\nThis WebPCoder is mostlly used for Animated WebP. Which is still not supported by Apple.","issue_id":1660696641847,"origin_id":781937713,"user_origin_id":6919743,"create_time":1613725439,"update_time":1613725439,"id":1666458097828,"updated_at":"2022-10-22T17:01:37.828000Z","created_at":"2022-10-22T17:01:37.828000Z"},{"_id":"635421f18041c95dfb11db6d","body":"Some trick for optimization about rendering RAM usage:\r\nhttps:\/\/github.com\/SDWebImage\/SDWebImage\/wiki\/Common-Problems#configuration-to-reduce-memory-pressure-aggressive\r\n\r\nThe most important one is that `SDWebImageAvoidDecodeImage`, which will not force to re-draw the bitmap image decoded by libwebp. However, the bad effect that this may slove down some FPS (the decoding is happended during rendering on screen, not in advance during loading)\r\n\r\n---\r\n\r\nActually, for JPEG\/PNG, the hardware-accelerated decoding speed is fast enough so Apple decide to `decoding when rendering on screen`. It's a lazy algorithm, and they can also release the frame buffer when disappear (next time need re-decoding), works great for most small images.\r\n\r\nHowever, for WebP, the decoding speed is slow, so if we `decoding when rendering on screen`, you will see a visible lag because the decoding blocking the rendering on main queue.","issue_id":1660696641847,"origin_id":781938643,"user_origin_id":6919743,"create_time":1613725539,"update_time":1613725868,"id":1666458097831,"updated_at":"2022-10-22T17:01:37.830000Z","created_at":"2022-10-22T17:01:37.830000Z"},{"_id":"635421f18041c95dfb11db6e","body":"> Some trick for optimization about rendering RAM usage:\r\n> https:\/\/github.com\/SDWebImage\/SDWebImage\/wiki\/Common-Problems#configuration-to-reduce-memory-pressure-aggressive\r\n\r\nThanks. Will try this solution.\r\n\r\n","issue_id":1660696641847,"origin_id":781943917,"user_origin_id":1101646,"create_time":1613726045,"update_time":1613726055,"id":1666458097834,"updated_at":"2022-10-22T17:01:37.833000Z","created_at":"2022-10-22T17:01:37.833000Z"},{"_id":"635421f18041c95dfb11db6f","body":"doesn't seem a possible solution if I need to convert an animated UIimage to webp Data.\r\nAt the moment I am using:\r\n`let webPData = SDImageCodersManager.shared.encodedData(with: newAnimatedimage, format: .webP, options: [SDImageCoderOption.encodeMaxFileSize: 1024 * 45])`\r\n\r\nBut the conversion is very slow and takes up a lot of RAM, many times it fails for memory leak.","issue_id":1660696641847,"origin_id":782230469,"user_origin_id":6886116,"create_time":1613756689,"update_time":1613756689,"id":1666458097836,"updated_at":"2022-10-22T17:01:37.836000Z","created_at":"2022-10-22T17:01:37.836000Z"},{"_id":"635421f18041c95dfb11db70","body":"If you can not get the suitable desired file size for WebP encoding, you'd better use `compressionQuality`, not that `encodeMaxFileSize`. For example, if one image which contains 4000x4000 pixels and it's a complicated graphics, product 45KB webp file size may cause libwebp to iterate more than 1000 times to reduce the accurate, which may cause RAM peak. (Not memory leak, just because it need that RAM for VP8 codec). You can just do the same thing using [libwebp command line](https:\/\/developers.google.com\/speed\/webp\/docs\/cwebp) on the Mac to see about how slow libwebp encoding with best size is.\r\n\r\nAnd, this issue and topic is talked about WebP Decoding, not Encoding...If there are something issue in encoding, we'd better open a new issue instead.","issue_id":1660696641847,"origin_id":782547898,"user_origin_id":6919743,"create_time":1613790830,"update_time":1613790986,"id":1666458097839,"updated_at":"2022-10-22T17:01:37.839000Z","created_at":"2022-10-22T17:01:37.839000Z"},{"_id":"635421f18041c95dfb11db71","body":"And, for WebP Encoding, libwebp provide one config:\r\n\r\n```\r\nWebPConfig.low_memory = 1;\r\n```\r\n\r\nWhat about use this to have a try ? SDWebImageWebPCoder can map the options from Objective-C code to C-level API, see:\r\nhttps:\/\/github.com\/SDWebImage\/SDWebImageWebPCoder\/blob\/master\/SDWebImageWebPCoder\/Classes\/SDWebImageWebPCoderDefine.h#L51\r\n","issue_id":1660696641847,"origin_id":782548673,"user_origin_id":6919743,"create_time":1613791159,"update_time":1613791159,"id":1666458097842,"updated_at":"2022-10-22T17:01:37.841000Z","created_at":"2022-10-22T17:01:37.841000Z"},{"_id":"635421f18041c95dfb11db72","body":"Hello, thank you for the reply. I did try that option enabling low memory usage but it's very slow.\r\nHowever i managed to do this even using more RAM but reducing the single frame size.\r\n\r\nAnd yes, the encodeMaxFileSize was an issue. I am using compressionQuality for the moment.\r\n\r\nI would like to do a faster encoding of an animated [SDImageFrame]. It takes about 10 seconds for a 60 frames animated image. (500x500px)\r\n\r\nThis is what I am doing at the moment:\r\n\r\n`let resizedData = SDImageCodersManager.shared.encodedData(with: newAnimatedimage, format: .webP, options: [SDImageCoderOption.encodeCompressionQuality: compression])`\r\n \r\nWhere `newAnimatedImage` is [SDImageFrame] of about 20-100 frames.","issue_id":1660696641847,"origin_id":782598654,"user_origin_id":6886116,"create_time":1613815213,"update_time":1613815297,"id":1666458097844,"updated_at":"2022-10-22T17:01:37.843000Z","created_at":"2022-10-22T17:01:37.843000Z"},{"_id":"635421f18041c95dfb11db73","body":"For `faster` encoding (don't care about the output size, it's a trade-off), there are more options from libwebp's manual:\r\n\r\n1. WebPConfig.method = 6 (cwebp's `-m6`)\r\n2. WebPConfig.quality = 0 (cwebp's `-q`)\r\n\r\nMore: https:\/\/developers.google.com\/speed\/webp\/docs\/cwebp, many lossy options may effect the encoding time and quality.\r\n\r\nActually I'm not expect at webp encoding. I focus on integrate the webp to iOS platform with easy-to-use interface...","issue_id":1660696641847,"origin_id":782602121,"user_origin_id":6919743,"create_time":1613816807,"update_time":1613816881,"id":1666458097846,"updated_at":"2022-10-22T17:01:37.846000Z","created_at":"2022-10-22T17:01:37.846000Z"},{"_id":"635421f18041c95dfb11db74","body":"You can also use `SDImageCoderEncodeMaxPixelSize` to limit the pixel size for encoding. Don't need to scale down by yourself before encoding. We provide the common support for thumbnail encoding, actually.\r\n\r\nhttps:\/\/github.com\/SDWebImage\/SDWebImageWebPCoder\/blob\/0.8.2\/SDWebImageWebPCoder\/Classes\/SDImageWebPCoder.m#L870","issue_id":1660696641847,"origin_id":782602713,"user_origin_id":6919743,"create_time":1613817051,"update_time":1613817289,"id":1666458097849,"updated_at":"2022-10-22T17:01:37.848000Z","created_at":"2022-10-22T17:01:37.848000Z"},{"_id":"635421f18041c95dfb11db75","body":"I understand that there is not good solution for keeping an animated WebP under 500KB with a 500x500px with a fast encoding.\r\nI am resizing the frames before because the resizing method I am using for the frames is very fast. I loose a lot of time during the encoding. ","issue_id":1660696641847,"origin_id":782603199,"user_origin_id":6886116,"create_time":1613817279,"update_time":1613817279,"id":1666458097851,"updated_at":"2022-10-22T17:01:37.850000Z","created_at":"2022-10-22T17:01:37.850000Z"}] comment

Just move to new issue from [this issue](https://github.com/SDWebImage/SDWebImageWebPCoder/issues/29#issuecomment-716067825) Looks like the issue still exists for ios < 14.0 Can reproduce on devices with ios 12 and ios 13 while trying...

performance

Hello, I'm trying to use animated webp images as cells for collection view and it works nice on new devices, but on devices like iPhone 7 I have such an...

use `xcframeworks` for dependencies update min dependencies version

Hi, using Package Manager and hitting the below unavailable in iOS 'UIActivityIndicatorViewStyleWhite' is unavailable: not available on visionOS amongst others. Can we have the Coder-Decoder working for VisionOS please? Which...

I want to use WebP format for animations instead of GIFs. However, I've noticed that SDImageWebPCoder is significantly slower, with a performance gap of tens of times compared to GIFs...

How to achieve the same results as `cwebp -metadata all` with options configuration.