Search code examples
androidimagejpegwebp

Image size is increased when converted from jpg to webp with quality value 100


I want to replace my .png and .jpg files in android project with .webp to reduce the app size.

I am verifying these 3 cases for jpg to webp conversion(for both .png and .jpg) :

  1. Lossy with 80% quality
  2. Lossy with 100% quality
  3. Lossless

for Case 1, size was reduced by ~30% as expected

But for cases 1 and 2, size was increased significantly(170KB of .jpg to 470KB of .webp) instead of decreasing.

Command used :

cwebp -q 100 input.jpg -o output.webp

This is working fine with .png images for all three cases where sizes are reduced when converted to .webp format.

But the same is not working with the .jpg image ? Does size reduction depend on .jpg image ? Is size guaranteed to reduce when converted from .jpg/.png to .webp ? Why did the size increase ?

Version of libwebp : libwebp-0.4.3 OS - Windows 64-bit


Solution

  • The problem you face is that with JPEG there is are large number of variables you can manipulate to get different compression. That is the benefit you get from lossy compression. Lossless compression tends to have few (if any options). In lossless compression, the tradeoff is time vs. compression. In lossy it is quality vs. compression.

    You are running a lossy compressed image through a second lossy compression process and getting rather unpredictable results.

    The real comparison would be to take your PNG images and compress them using webp and JPEG using various settings to see what quality you get compared to the compression.