DEV Community

Mageshwaran
Mageshwaran

Posted on

Compress image in python

Yesterday i wrote a article in Dev about

Google Chrome Extension

I upload sample images of the Google Chrome Extension - New Tab a New Quote but it fails, i tried it multiple time, because of the file size and the network problem which i faced.
So i decided to compress the image using python

   from PIL import Image
   path = "img/Screenshot 6.png"
   image = Image.open(path)
   image = image.convert('RGB')
   image.save("img/Screenshot 6e.jpg",quality=20,optimize=True)
Enter fullscreen mode Exit fullscreen mode

you can see the difference
Alt Text

8MB

Alt Text

275KB

Alt Text

Thanks you, have a great day ahead.😎

Top comments (0)