Skip to content

Instantly share code, notes, and snippets.

@agrif
Created September 6, 2012 18:55
Show Gist options
  • Save agrif/3659457 to your computer and use it in GitHub Desktop.
Save agrif/3659457 to your computer and use it in GitHub Desktop.
Python 2.7.2 (default, Apr 1 2012, 14:18:41)
[GCC 4.5.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> # load up a test file
>>> import OIL
>>> i = OIL.Image.load("input.png")
>>> i.get_size()
(800, 600)
>>> # save it to a stringio object
>>> import StringIO
>>> dest = StringIO.StringIO()
>>> i.save(dest)
>>> # see if it worked!
>>> len(dest.getvalue())
718602
>>> # load the stringio data into a new image
>>> dest.seek(0)
>>> newi = OIL.Image.load(dest)
>>> newi.get_size()
(800, 600)
>>> # !!!
@agrif
Copy link
Author

agrif commented Sep 6, 2012

Python 2.7.2 (default, Apr  1 2012, 14:18:41) 
[GCC 4.5.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import OIL
>>> import urllib2
>>> i = OIL.Image.load(urllib2.urlopen("https://a248.e.akamai.net/assets.github.com/images/modules/header/logo_gist.png?1334862346"))
>>> i.get_size()
(655, 177)
>>> 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment