Guest User

Untitled

a guest
Jan 20th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. import Image
  2.  
  3. im = Image.open("image.jpg")
  4.  
  5. if im.size == (7200, 4800):
  6. out = im.resize((3300,2200), Image.ANTIALIAS)
  7. elif im.size == (4800,7200):
  8. out = im.resize((2200,3300), Image.ANTIALIAS)
  9.  
  10. out.show()
  11.  
  12. dpi = im.info['dpi'] # Warning, throws KeyError if no DPI was set to begin with
  13.  
  14. # resize, etc.
  15.  
  16. out.save("out.jpg", dpi=dpi)
Add Comment
Please, Sign In to add comment