Skip to content

Nuffknacker/imagesize_py

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

imagesize

https://travis-ci.org/shibukawa/imagesize_py.svg?branch=master

This module analyzes JPEG/JPEG 2000/PNG/GIF/TIFF/SVG image headers and returns image size.

import imagesize

width, height = imagesize.get("test.png")
print(width, height)

This module is a pure Python module.

API

  • imagesize.get(filepath)

    Returns image size (width, height).

Benchmark

It only parses headers, and ignores pixel data. So it is much faster than Pillow.

module result
imagesize (pure Python) 1.077 seconds per 100 000 times
Pillow 10.569 seconds per 100 000 times

I tested on MacBookPro (2014/Core i7) with 125kB PNG files.

Restriction

  • TIFF

    It can returns only first picture's size because of restriction of API design.

    It supports only small TIFF file. BigTIFF support is not implemented.

Development

Run test with the following command:

python -m unittest

License

MIT License

Thanks

I referred to the following code:

I use sample image from here:

Thank you for feedback:

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%