WEBP Compression

Ask for help and post your question on how to use XnView MP.

Moderators: helmut, XnTriq, xnview

Post Reply
Xn User
Posts: 227
Joined: Sat Jan 05, 2019 1:16 pm

WEBP Compression

Post by Xn User »

Hi )

I can not understand , what in your version WEBP differ presets for compress level and absent compress 32 bit color , why this so ?

https://github.com/webmproject/libwebp
https://github.com/jacklicn/libwebp

Decode:
WebPGetDecoderVersion
WebPGetInfo
WebPDecodeRGBA
WebPDecodeARGB
WebPDecodeBGRA
WebPDecodeBGR
WebPDecodeRGB

Encode:
WebPGetEncoderVersion
WebPEncodeRGBA
WebPEncodeBGRA
WebPEncodeRGB
WebPEncodeBGR
WebPEncodeLosslessRGBA
WebPEncodeLosslessBGRA
WebPEncodeLosslessRGB
WebPEncodeLosslessBGR

and :

-preset must come first, as it overwrites other parameters
-z <int> ............... activates lossless preset with given
level in [0:fast, ..., 9:slowest]

-m <int> ............... compression method (0=fast, 6=slowest)

as I understand , in your XnView MP and XnConvert available presets only for lossy compression , that's why as I understand , I can not compress in lossless mode with maximum force )

Also , in your XnView MP and XnConvert absent RGBA compression for WEBP , although according to the standard this modes available in WEBP , why so ?

https://www.mediafire.com/file/xc68hk9i ... 4.rar/file

and from https://developers.google.com/speed/web ... iner?hl=en

Simple File Format (Lossless)

Note: Older readers may not support files using the lossless format.

This layout SHOULD be used if the image requires lossless encoding (with an optional transparency channel) and does not require advanced features provided by the extended format.

Simple File Format (Lossless)

Note: Older readers may not support files using the lossless format.

This layout SHOULD be used if the image requires lossless encoding (with an optional transparency channel) and does not require advanced features provided by the extended format.

Simple WebP (lossless) file format:

0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
| WebP file header (12 bytes) |
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
: 'VP8L' Chunk :
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

'VP8L' Chunk:

0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| ChunkHeader('VP8L') |
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
: VP8L data :
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

VP8L data: Chunk Size bytes
VP8L bitstream data.

The current specification of the VP8L bitstream can be found at WebP Lossless Bitstream Format. Note that the VP8L header contains the VP8L image width and height. That is assumed to be the width and height of the canvas.
Extended File Format

Note: Older readers may not support files using the extended format.

An extended format file consists of:

A 'VP8X' Chunk with information about features used in the file.

An optional 'ICCP' Chunk with a color profile.

An optional 'ANIM' Chunk with animation control data.

Image data.

An optional 'EXIF' Chunk with Exif metadata.

An optional 'XMP ' Chunk with XMP metadata.

An optional list of unknown chunks.

For a still image, the image data consists of a single frame, which is made up of:

An optional alpha subchunk.

A bitstream subchunk.

For an animated image, the image data consists of multiple frames. More details about frames can be found in the Animation section.

All chunks necessary for reconstruction and color correction, that is, 'VP8X', 'ICCP', 'ANIM', 'ANMF', 'ALPH', 'VP8 ', and 'VP8L', MUST appear in the order described earlier. Readers SHOULD fail when chunks necessary for reconstruction and color correction are out of order.

Metadata and unknown chunks MAY appear out of order.

Rationale: The chunks necessary for reconstruction should appear first in the file to allow a reader to begin decoding an image before receiving all of the data. An application may benefit from varying the order of metadata and custom chunks to suit the implementation.

Extended WebP file header:

0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
| WebP file header (12 bytes) |
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| ChunkHeader('VP8X') |
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Rsv|I|L|E|X|A|R| Reserved |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Canvas Width Minus One | ...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
... Canvas Height Minus One |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Reserved (Rsv): 2 bits
MUST be 0. Readers MUST ignore this field.
ICC profile (I): 1 bit
Set if the file contains an 'ICCP' Chunk.
Alpha (L): 1 bit
Set if any of the frames of the image contain transparency information ("alpha").
Exif metadata (E): 1 bit
Set if the file contains Exif metadata.
XMP metadata (X): 1 bit
Set if the file contains XMP metadata.
Animation (A): 1 bit
Set if this is an animated image. Data in 'ANIM' and 'ANMF' Chunks should be used to control the animation.
Reserved (R): 1 bit
MUST be 0. Readers MUST ignore this field.
Reserved: 24 bits
MUST be 0. Readers MUST ignore this field.
Canvas Width Minus One: 24 bits
1-based width of the canvas in pixels. The actual canvas width is 1 + Canvas Width Minus One.
Canvas Height Minus One: 24 bits
1-based height of the canvas in pixels. The actual canvas height is 1 + Canvas Height Minus One.

The product of Canvas Width and Canvas Height MUST be at most 2^32 - 1.

Future specifications may add more fields. Unknown fields MUST be ignored.
Last edited by XnTriq on Mon Mar 10, 2025 2:27 am, edited 1 time in total.
Reason: fixed typo in subject
User avatar
xnview
Author of XnView
Posts: 46235
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: WEBP Comoression

Post by xnview »

Xn User wrote: Mon Jan 20, 2025 4:20 pm -preset must come first, as it overwrites other parameters
-z <int> ............... activates lossless preset with given
level in [0:fast, ..., 9:slowest]

-m <int> ............... compression method (0=fast, 6=slowest)

as I understand , in your XnView MP and XnConvert available presets only for lossy compression , that's why as I understand , I can not compress in lossless mode with maximum force )
These options from cwebp are not yet available
Also , in your XnView MP and XnConvert absent RGBA compression for WEBP , although according to the standard this modes available in WEBP , why so ?
What do you means?
Pierre.
Xn User
Posts: 227
Joined: Sat Jan 05, 2019 1:16 pm

Re: WEBP Comoression

Post by Xn User »

xnview wrote: Wed Jan 22, 2025 2:21 pm What do you means?
I mean what in WEBP available six methods for lossy compression and nine methods for lossless compression , however I can use only first five of six methods , and method 6 available , but absolutely not workin if I use lossless compression mode )
User avatar
xnview
Author of XnView
Posts: 46235
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: WEBP Comoression

Post by xnview »

the compression method option is the -m option of cwebp
Pierre.
Xn User
Posts: 227
Joined: Sat Jan 05, 2019 1:16 pm

Re: WEBP Comoression

Post by Xn User »

But why in XnView MP and XnConvert 1.102 method five and method six not different ? If I try use XnConvert 1.90 , then there method five and method six different and sometimes method six have smaller file size than with the method five )
But in latest version XnView MP and XnConvert this result not possible , method six always worse than method five )
Xn User
Posts: 227
Joined: Sat Jan 05, 2019 1:16 pm

Re: WEBP Comoression

Post by Xn User »

xnview wrote: Wed Jan 22, 2025 2:21 pm What do you means?
And I still not understand , why I can write only RBB WEBP I mean 24 bit , but I can not write RGBA WEBP files I mean 32 bit , this at all possible or no ?
User avatar
xnview
Author of XnView
Posts: 46235
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: WEBP Comoression

Post by xnview »

Xn User wrote: Wed Jan 22, 2025 4:42 pm
xnview wrote: Wed Jan 22, 2025 2:21 pm What do you means?
And I still not understand , why I can write only RBB WEBP I mean 24 bit , but I can not write RGBA WEBP files I mean 32 bit , this at all possible or no ?
you can write RGBA WebP image
Pierre.
Xn User
Posts: 227
Joined: Sat Jan 05, 2019 1:16 pm

Re: WEBP Comoression

Post by Xn User »

xnview wrote: Thu Jan 23, 2025 2:30 pm you can write RGBA WebP image
You right , but I not understand , why so :
If I write WEBP R 255 / G 255 / B 255 / A 255 = 24 bit always , even if I select as 32 bit
If I write WEBP R 255 / G 255 / B 255 / A 254 = 32 bit always
why so ?
User avatar
xnview
Author of XnView
Posts: 46235
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: WEBP Comoression

Post by xnview »

Xn User wrote: Wed Jan 22, 2025 4:11 pm But why in XnView MP and XnConvert 1.102 method five and method six not different ? If I try use XnConvert 1.90 , then there method five and method six different and sometimes method six have smaller file size than with the method five )
But in latest version XnView MP and XnConvert this result not possible , method six always worse than method five )
i have tested and have the same output file than cwebp (-m)
Pierre.
User avatar
xnview
Author of XnView
Posts: 46235
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: WEBP Comoression

Post by xnview »

Xn User wrote: Thu Jan 23, 2025 2:58 pm If I write WEBP R 255 / G 255 / B 255 / A 255 = 24 bit always , even if I select as 32 bit
ok i understand now. libwebp write as 24bits if alpha=255
Pierre.
Xn User
Posts: 227
Joined: Sat Jan 05, 2019 1:16 pm

Re: WEBP Comoression

Post by Xn User »

Also , force and method compression in lossy and lossless , you can see what m5 and m6 in lossless not differ on size and m5 and m6 in lossy differ on size )
That's why I think , method 6 in lossless mode always absent

https://www.mediafire.com/file/kpbsz2un ... .webp/file
https://www.mediafire.com/file/qaf4rh8w ... .webp/file
https://www.mediafire.com/file/y90m4s09 ... .webp/file
https://www.mediafire.com/file/49sp3s6g ... .webp/file
Xn User
Posts: 227
Joined: Sat Jan 05, 2019 1:16 pm

Re: WEBP Comoression

Post by Xn User »

As me can get maximum compression with method 6 use lossless mode in WEBP and correct save 32 bit with alpha-channel 255 ?
Post Reply