Advertisement
Guest User

python image resize

a guest
Jul 23rd, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. import PIL
  2. import sys
  3. from PIL import Image
  4.  
  5. baseheight = 660
  6. img = Image.open(sys.argv[1])
  7. print(img.size)
  8. if img.size[1] < baseheight:
  9. print('Image too small')
  10. else:
  11. hpercent = (baseheight / float(img.size[1]))
  12. wsize = int((float(img.size[0]) * float(hpercent)))
  13. img = img.resize((wsize, baseheight), PIL.Image.ANTIALIAS)
  14. img.save("resized_" + sys.argv[1])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement