Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 25th, 2012  |  syntax: None  |  size: 0.33 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Get image width and height without downloading in PYTHON
  2. import cStringIO
  3. import urllib
  4. import Image
  5. file = urllib.urlopen('http://static.php.net/www.php.net/images/php.gif')
  6. im = cStringIO.StringIO(file.read())
  7. img = Image.open(im)
  8. print img.format, img.size, img.mode
  9. GIF (120, 67) P
  10. width, height = img.size
  11. print width, height