DEV Community

Mageshwaran
Mageshwaran

Posted on

5 1

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.😎

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs