R
R
Robot2052020-08-06 20:01:55
Python
Robot205, 2020-08-06 20:01:55

How to reduce multiple images?

Hello. The folder has 1000 images of 5mb each. How can I reduce them all? I can only resize 1 image

from PIL import Image
img=Image.open('C:\\Users\\user\\Desktop\\image\\IMG_20200730_104524.jpg')
img.save("IMG_20200730_104524_compress.jpg", format="JPEG", quality=30)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey, 2020-08-06
@Robot205

import os
from PIL import Image

for i in os.listdir('C:\\Users\\user\\Desktop\\image'):
    img=Image.open(i)
    img.save(i, format="JPEG", quality=30)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question