본문 바로가기

Python/Basic

[Python] Pillow 이미지 사이즈 확인

반응형

 

 

https://note.nkmk.me/en/python-opencv-pillow-image-size/

 

Get image size (width, height) with Python, OpenCV, Pillow (PIL) | note.nkmk.me

This article describes how to get the image size (width, height) in Python with OpenCV and Pillow (PIL).The image size can be obtained as a tuple with the attribute shape of ndarray in OpenCV and the attribute size of PIL.Image in Pillow (PIL). Note that t

note.nkmk.me

 

from PIL import Image

im = Image.open('data/src/lena.jpg')

print(im.size)
print(type(im.size))
# (400, 225)
# <class 'tuple'>

w, h = im.size
print('width: ', w)
print('height:', h)
# width:  400
# height: 225
반응형

'Python > Basic' 카테고리의 다른 글

[Python] curve fitting  (1) 2022.09.30
[Python] PDF 관련 패키지 정리  (2) 2022.08.05
[Python] 파일 관련  (0) 2022.07.19
[Python] Excel, Word 다루기  (0) 2021.07.26
[Python] XlsxWriter - Excel 다루기  (0) 2021.07.26