Poor results when converting large JPG images to WebP?

120 views
Skip to first unread message

lian...@hotmail.it

unread,
Mar 16, 2019, 12:12:27 PM3/16/19
to WebP Discussion
I have tried to convert this 8K image both to JPG and WebP at lower resolutions: https://wallpapersite.com/images/wallpapers/mountains-7360x4912-rocks-4k-8k-6143.jpg

But in some cases the JPG conversion gave better results than Webp: lower file size for the same resolution.

These are the commands i've run, and results:


# The cwebp bin i have used is the one in libwebp-1.0.2-linux-x86-64
#original JPG file size is 8.9 MB


#scale to 150px width, auto height (preserve AR)
ffmpeg
-y -i inputFile.jpg -f image2 -vf scale=150:-1 -vframes 1 outputFile.jpg

#resulting file size: 6.4 KB


cwebp  
-resize 150 0 -m 6 inputFile.jpg -o outputFile.webp

#resulting file size: 4.1 KB




#scale to 300px width, auto height (preserve AR)
ffmpeg
-y -i inputFile.jpg -f image2 -vf scale=300:-1 -vframes 1 outputFile.jpg

#resulting file size: 17.6 KB


cwebp  
-resize 300 0 -m 6 inputFile.jpg -o outputFile.webp

#resulting file size: 14.0 KB




#scale to 600px width, auto height (preserve AR)
ffmpeg
-y -i inputFile.jpg -f image2 -vf scale=600:-1 -vframes 1 outputFile.jpg

#resulting file size: 47.4 KB


cwebp  
-resize 600 0 -m 6 inputFile.jpg -o outputFile.webp

#resulting file size: 49.1 KB




#scale to 1200px width, auto height (preserve AR)
ffmpeg
-y -i inputFile.jpg -f image2 -vf scale=1200:-1 -vframes 1 outputFile.jpg

#resulting file size: 140.8 KB


cwebp  
-resize 1200 0 -m 6 inputFile.jpg -o outputFile.webp

#resulting file size: 180.4 KB




#scale to 1680px width, auto height (preserve AR)
ffmpeg
-y -i inputFile.jpg -f image2 -vf scale=1680:-1 -vframes 1 outputFile.jpg

#resulting file size: 225.4 KB


cwebp  
-resize 1680 0 -m 6 inputFile.jpg -o outputFile.webp

#resulting file size: 333.8 KB




#scale to 2560px width, auto height (preserve AR)
ffmpeg
-y -i inputFile.jpg -f image2 -vf scale=2560:-1 -vframes 1 outputFile.jpg

#resulting file size: 434.9 KB


cwebp  
-resize 2560 0 -m 6 inputFile.jpg -o outputFile.webp

#resulting file size: 750.3 KB




#scale to 3840px width, auto height (preserve AR)
ffmpeg
-y -i inputFile.jpg -f image2 -vf scale=3840:-1 -vframes 1 outputFile.jpg

#resulting file size: 797.8 KB


cwebp  
-resize 3840 -m 6 inputFile.jpg -o outputFile.webp

#resulting file size: 1.5 MB


I think this is the only file that gave me better results with JPG than WEbP , maybe it has particular features/colors
that make WebP struggle?

I would like to try more advanced cwebp parameters like -psnr , -af , -pass , but i don't know how to use them effectively.
Anyone can give me a hint? 
Thanks







Pascal Massimino

unread,
Mar 16, 2019, 12:23:10 PM3/16/19
to WebP Discussion
Hi,

On Sat, Mar 16, 2019 at 5:12 PM <lian...@hotmail.it> wrote:
I have tried to convert this 8K image both to JPG and WebP at lower resolutions: https://wallpapersite.com/images/wallpapers/mountains-7360x4912-rocks-4k-8k-6143.jpg

But in some cases the JPG conversion gave better results than Webp: lower file size for the same resolution.

keep in mind that, for lossy compression, in addition to final file-size you have to keep an eye at the amount of loss that occurred.
Given that JPEG and WebP operate with different block-size (and prediction method), there's not necessarily a 1:1 correspondence
between file-size for a given resolution. The distortion can vary too, to compensate for the file differences.
Lastly, ffmpeg and cwebp are using different downscaling algorithm by default, which is another variable on the line.

What i would, in your case is:
  * use the 'get_disto' command-line tool to get an idea of the distortion between the source, the jpeg and the webp images.
  * compress the JPEG first, record the file size, and then use it as target size for cwebp:  'cwebp -size the_jpg_size -resize ....'
    Then you can see if there's a real visual difference.

hope it helps!
skal/

note: for large images, there's an arcane inherent limitation of WebP format which is call "Partition0 size limit" which may
affect how much compression we can squeeze in for large images. But i don't think it's the primary culprit here.



--
You received this message because you are subscribed to the Google Groups "WebP Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webp-discuss...@webmproject.org.
To post to this group, send email to webp-d...@webmproject.org.
Visit this group at https://groups.google.com/a/webmproject.org/group/webp-discuss/.
For more options, visit https://groups.google.com/a/webmproject.org/d/optout.

L B

unread,
Mar 16, 2019, 2:17:49 PM3/16/19
to WebP Discussion

What i would, in your case is:
  * use the 'get_disto' command-line tool to get an idea of the distortion between the source, the jpeg and the webp images.
  * compress the JPEG first, record the file size, and then use it as target size for cwebp:  'cwebp -size the_jpg_size -resize ....'
    Then you can see if there's a real visual difference.


Thanks.
Your second suggestion works. 

Then i tried get_disto to check the distortion of the resulting files, but it gave me:
Error while computing the distortion.

Why ?
I have given the compressed JPG as the first parameter: https://s3-eu-west-1.amazonaws.com/save-by-booking-v2/public/uat/img8kesempio_4k
The second parameter was the original JPG i already linked 

Also passing the compressed webp as the first parameter https://s3-eu-west-1.amazonaws.com/save-by-booking-v2/public/uat/webp/img8kesempio_4k and the original JPG as the second one, resulted in 
Error while computing the distortion.


The WebP file size is about 40% smaller than the JPG compressed one, but a significant quality loss can be noticed.

This is a cmd i run 

#from original 8K , to 4K
cwebp
-resize 3840 0 -m 6 -q 100 -size <expectedMaxWebPSize> -af -pass 10 originalFile.jpg -o outputFile.webp

where <expectedMaxWebPSize> is the size of the compressed JPG multiplied by 0.60

Indeed the size gets forced correctly , but i expected also a quality close to the compressed JPG, because typically when the original input images are smaller than this one, the Webp compressed image is like -30%/-40% than the one compressed in JPG, and maintains a comparable quality level as well.

So i don't know, maybe the WebP power is no more for 8K or bigger images?
Or should i try other tricks ?

James Zern

unread,
Mar 21, 2019, 7:48:08 PM3/21/19
to WebP Discussion
Hi,


On Saturday, March 16, 2019 at 11:17:49 AM UTC-7, L B wrote:

What i would, in your case is:
  * use the 'get_disto' command-line tool to get an idea of the distortion between the source, the jpeg and the webp images.
  * compress the JPEG first, record the file size, and then use it as target size for cwebp:  'cwebp -size the_jpg_size -resize ....'
    Then you can see if there's a real visual difference.


Thanks.
Your second suggestion works. 

Then i tried get_disto to check the distortion of the resulting files, but it gave me:
Error while computing the distortion.

Why ?

get_disto requires the compressed image's resolution to match the original. In this case you can resize the original to lossless png or webp (use 'cwebp -resize 3840 0 -lossless ...' for the webp side to use the same downscaling as the lossy compression).
Reply all
Reply to author
Forward
0 new messages