Skip to content

Instantly share code, notes, and snippets.

@augustogoulart
Created August 3, 2017 01:56
Show Gist options
  • Save augustogoulart/cf29881beba904990716c1fc0756a7c4 to your computer and use it in GitHub Desktop.
Save augustogoulart/cf29881beba904990716c1fc0756a7c4 to your computer and use it in GitHub Desktop.
Simple profiler to understand Pillow memory usage working with images in memory.
from urllib.request import urlopen
from PIL import Image
from memory_profiler import profile
@profile
def run():
img = Image.open(urlopen("https://graviolastatics.s3.amazonaws.com/thumbnails/card.jpg"))
thumbnail = img.resize((300, 300), Image.ANTIALIAS)
thumbnail.show()
if __name__ == "__main__":
run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment