Advertisement
sreejith2904

img_compressor.py

May 11th, 2011
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.34 KB | None | 0 0
  1. import os
  2. from PIL import Image
  3. print "Enter the folder in which the image files are present: "
  4. folder_name = raw_imput
  5. n = 1
  6. a  = os.listdir(folder_name)
  7. for i in a:
  8.     if i != 'compress.py':
  9.         img = Image.open(i)
  10.         x = img.size[0]
  11.         y = img.size[1]
  12.        
  13.         compress = img.resize((x,y),Image.BILINEAR)
  14.         compress.save(str(n) + '.jpg')
  15.         n+=1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement