1

Show PIL image object in browser

 2 years ago
source link: https://fann.im/blog/2010/06/30/show-pil-image-object-in-browser/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Show PIL image object in browser

Jun 30, 2010

在浏览器显示 PIL 处理过的图片对象。

Using PIL module, you can resize or crop an image and return an image object. After that, I want to show the resized-image-object in browser. Here it is.

pic = thumbPicture()
f = StringIO()
pic.save(f,'JPEG')
f.seek(0)
shutil.copyfileobj(f,self.wfile)
self.sendHeader(contenttype = 'image/jpeg',contentlength = f.tell())
f.close()

Was this page helpful?


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK