• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..07-May-2022-

build/lib/H03-May-2022-365316

imagesize.egg-info/H07-May-2022-7466

test/H09-Nov-2021-410334

LICENSE.rstH A D09-Nov-20211.1 KiB2015

MANIFEST.inH A D09-Nov-202160 43

PKG-INFOH A D09-Nov-20211.4 KiB4538

README.rstH A D09-Nov-20212.3 KiB9362

imagesize.pyH A D09-Nov-202113 KiB365316

setup.cfgH A D09-Nov-202167 85

setup.pyH A D09-Nov-20211.5 KiB4942

README.rst

1imagesize
2=============
3
4.. image:: https://travis-ci.org/shibukawa/imagesize_py.svg?branch=master
5    :target: https://travis-ci.org/shibukawa/imagesize_py
6
7This module analyzes JPEG/JPEG 2000/PNG/GIF/TIFF/SVG/Netpbm image headers and returns image size or DIP.
8
9.. code:: python
10
11   import imagesize
12
13   width, height = imagesize.get("test.png")
14   print(width, height)
15
16   width, height = imagesize.getDPI("test.png")
17   print(width, height)
18
19This module is a pure Python module. You can use file like object like file or something like ``io.BytesIO``.
20
21API
22-----
23
24* ``imagesize.get(filepath)``
25
26  Returns image size (width, height).
27
28* ``imagesize.getDPI(filepath)``
29
30  Returns image DPI (width, height).
31
32Benchmark
33------------
34
35It only parses headers, and ignores pixel data. So it is much faster than Pillow.
36
37.. list-table::
38   :header-rows: 1
39
40   - * module
41     * result
42   - * imagesize (pure Python)
43     * 1.077 seconds per 100 000 times
44   - * Pillow
45     * 10.569 seconds per 100 000 times
46
47I tested on MacBookPro (2014/Core i7) with 125kB PNG files.
48
49Development
50---------------
51
52Run test with the following command:
53
54.. code:: bash
55
56   python -m unittest
57
58License
59-----------
60
61MIT License
62
63Thanks
64----------
65
66I referred to the following code:
67
68* http://markasread.net/post/17551554979/get-image-size-info-using-pure-python-code
69* https://stackoverflow.com/questions/8032642/how-to-obtain-image-size-using-standard-python-class-without-using-external-lib
70
71I use sample image from here:
72
73* https://www.nightprogrammer.org/development/multipage-tiff-example-download-test-image-file/
74
75Thank you for feedback:
76
77* tk0miya (https://github.com/tk0miya)
78* shimizukawa (https://github.com/shimizukawa)
79* xantares (https://github.com/xantares)
80* Ivan Zakharyaschev (https://github.com/imz)
81* Jon Dufresne (https://github.com/jdufresne)
82* Geoff Lankow (https://github.com/darktrojan)
83* Hugo (https://github.com/hugovk)
84* Jack Cherng (https://github.com/jfcherng)
85* Tyler A. Young (https://github.com/s3cur3)
86* Mark Browning (https://github.com/mabrowning)
87* ossdev07 (https://github.com/ossdev07)
88* Nicholas-Schaub (https://github.com/Nicholas-Schaub)
89* Nuffknacker (https://github.com/Nuffknacker)
90* Hannes Römer (https://github.com/hroemer)
91* mikey (https://github.com/ffreemt)
92* Marco (https://github.com/marcoffee)
93