userv
userv

Reputation: 2617

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

Upvotes: 20

Views: 12696

Answers (2)

Praveen Sripati
Praveen Sripati

Reputation: 33495

Including the reference to the Google documentation who came with the WebP format about the possibility of the file size getting increased when converted into the WebP format.

Yes, usually when converting from a lossy format to WebP lossless or vice versa. This is mainly due to the colorspace difference (YUV420 vs ARGB) and the conversion between these.

https://developers.google.com/speed/webp/faq#can_a_webp_image_grow_larger_than_its_source_image

Upvotes: 3

user3344003
user3344003

Reputation: 21627

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.

Upvotes: 5

Related Questions