View Single Post
Old 12-15-2015, 01:21 PM   #3
rubeus
Banned
rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.rubeus ought to be getting tired of karma fortunes by now.
 
Posts: 272
Karma: 1224588
Join Date: Sep 2014
Device: Sony PRS 650
How to get width and height from an image?

You need:

Python Interpreter > 3 and PIL library installed

or

the internal builtin Python Interpreter from 0.9.0 and up.

Code:
from PIL import Image
from io import BytesIO
Code:
    for (id, href, mime) in bk.image_iter():
        im = Image.open(BytesIO(bk.readfile(id)))
        (width, height) = im.size
        print ('id={} href={} mime={} width={} height={}'.format(id, href, mime, width,height))
rubeus is offline   Reply With Quote