Skip to content

Low compression quality compared to cwebp CLI tool #116

Open
@pawelmtw

Description

@pawelmtw

Description

When using SDImageWebPCoder to encode images with lossless options, the resulting file size and compression quality appear to be worse compared to Google's cwebp command-line tool. Despite both using lossless compression settings, SDImageWebPCoder produces slightly lower quality images, with visible artifacts and banding on gradients and shadows.

I experimented with different encoding options such as: encodeCompressionQuality, encodeWebPMethod, encodeWebPPass etc. Despite these adjustments, the output quality and file size were still worse compared to cwebp -lossless. This suggests a fundamental difference in how the WebP encoding is implemented in SDImageWebPCoder versus the official WebP compression tool.

Code

SDImageWebPCoder:

if let data = SDImageWebPCoder.shared.encodedData(with: nsImage, format: .webP, options: [.encodeWebPLossless: 1]) {
  try data.write(to: destination))
}

cwebp:

cwebp -lossless input.png -o output.webp

Results

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions