Saved webp images are 3x bigger than jpg in OpenCV

Viewed 1100

For some reason, on my Ubuntu 20.04 machine when I use OpenCV in Python like:

cv2.imwrite("myfile.webp", cv2image)

in my code, the file of 800x600 px has about 300 KiB while if I do:

cv2.imwrite("myfile.jpg", cv2image)

the output file of the same pixel size has about 100 KiB.

Why is that, if webp should have 25% less in size than jpg?

Or do I have to set some options first?

P.S. for png:

cv2.imwrite("myfile.png", cv2image)

the size is about 500 KiB.

2 Answers

SOLVED! It should be like this to work:

cv2.imwrite("myfile.webp", cv2image, [int(cv2.IMWRITE_WEBP_QUALITY), 20])

Now, the file has 4 kB ;D

Related