From 6a0f5dc73c2a465df89b22a9fb2d20fd72d4445d Mon Sep 17 00:00:00 2001 From: DreamPiggy Date: Tue, 7 Apr 2020 19:45:33 +0800 Subject: [PATCH] Fix that the max file size encoding need to increase the passes used by libwebp, we choose to use 6 from cwebp command line --- SDWebImageWebPCoder/Classes/SDImageWebPCoder.m | 1 + 1 file changed, 1 insertion(+) diff --git a/SDWebImageWebPCoder/Classes/SDImageWebPCoder.m b/SDWebImageWebPCoder/Classes/SDImageWebPCoder.m index e05fa1f..5a47a91 100644 --- a/SDWebImageWebPCoder/Classes/SDImageWebPCoder.m +++ b/SDWebImageWebPCoder/Classes/SDImageWebPCoder.m @@ -781,6 +781,7 @@ static CGSize SDCalculateThumbnailSize(CGSize fullSize, BOOL preserveAspectRatio } config.target_size = (int)fileSize; // Max filesize for output, 0 means use quality instead + config.pass = fileSize > 0 ? 6 : 1; // Use 6 passes for file size limited encoding, which is the default value of `cwebp` command line config.thread_level = 1; // Thread encoding for fast config.lossless = 0; // Disable lossless encoding (If we need, can add new Encoding Options in future version) picture.use_argb = config.lossless; // Lossy encoding use YUV for internel bitstream