pythonpython-imaging-librarytornadofilesize

How to get image size (bytes) using PIL


I found out how to use PIL to get the image dimensions, but not the file size in bytes. I need to know the file size to decide if the file is too big to be uploaded to the database.


Solution

  • Try:

    import os
    print os.stat('somefile.ext').st_size