How do I get a size of a pictures sides with PIL or any other Python library?
相关问题
- Views base64 encoded blob in HTML with PHP
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
According to the documentation.
Since
scipy
'simread
is deprecated, useimageio.imread
.pip install imageio
height, width, channels = imageio.imread(filepath).shape
You can use Pillow (Website, Documentation, GitHub, PyPI). Pillow has the same interface as PIL, but works with Python 3.
Installation
If you don't have administrator rights (sudo on Debian), you can use
Other notes regarding the installation are here.
Code
Speed
This needed 3.21 seconds for 30336 images (JPGs from 31x21 to 424x428, training data from National Data Science Bowl on Kaggle)
This is probably the most important reason to use Pillow instead of something self-written. And you should use Pillow instead of PIL (python-imaging), because it works with Python 3.
Alternative #1: Numpy
Alternative #2: Pygame