Issue
I'm trying to convert the jpg images into new generation WebP format. I used PIL for that and everything working perfectly! But my problem is when the program compresses a JPG file which is 134KB and when it converted into WebP it became 108KB.
How I can shorten the size of the WebP image ?, I want to compress the quality.
My code looks like this:
from PIL import Image
image = Image.open('my-image.jpg')
image = image.convert('RGB')
image.save('my-image.jpg.webp', 'webp')
Does anybody know how we can again decrease the size of the converted WebP images?
Solution
Set the quality parameter while saving the image.
image.save('my-image.jpg.webp', 'webp', optimize = True, quality = 10)
Save the picture with desired quality. To change the quality of image, set the quality variable at your desired level, The more the value of quality variable and lesser the compression
Answered By - Ashish M J
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.