Skip to content

Commit e25194e

Browse files
authored
Merge pull request #36 from SDWebImage/fix_max_file_size_passes
Fix that the max file size encoding need to increase the passes used by libwebp, we choose to use 6 from cwebp command line
2 parents ee7665e + 6a0f5dc commit e25194e

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

SDWebImageWebPCoder/Classes/SDImageWebPCoder.m

+1
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,7 @@ - (nullable NSData *)sd_encodedWebpDataWithImage:(nullable CGImageRef)imageRef q
781781
}
782782

783783
config.target_size = (int)fileSize; // Max filesize for output, 0 means use quality instead
784+
config.pass = fileSize > 0 ? 6 : 1; // Use 6 passes for file size limited encoding, which is the default value of `cwebp` command line
784785
config.thread_level = 1; // Thread encoding for fast
785786
config.lossless = 0; // Disable lossless encoding (If we need, can add new Encoding Options in future version)
786787
picture.use_argb = config.lossless; // Lossy encoding use YUV for internel bitstream

0 commit comments

Comments
 (0)