Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
Tags
- vaadin
- SSL
- plugin
- react
- R
- Express
- Python
- hadoop
- MSSQL
- 보조정렬
- mapreduce
- Sqoop
- 공정능력
- mybatis
- GIT
- IntelliJ
- Java
- table
- Eclipse
- SPC
- xPlatform
- tomcat
- Android
- Kotlin
- NPM
- window
- es6
- JavaScript
- Spring
- SQL
Archives
- Today
- Total
DBILITY
python 사진 이미지 다루기(image open, resize) 본문
728x90
반응형
pip install pillow 또는 나는 intellij를 사용하니 Python Packages Window에서 설치했음.
사용법은 아래 공식사이트를 참고하자.
Pillow
Pillow is the friendly PIL fork by Alex Clark and Contributors. PIL is the Python Imaging Library by Fredrik Lundh and Contributors. Pillow for enterprise is available via the Tidelift Subscription...
pillow.readthedocs.io
import os
import shutil
from PIL import Image
target_directory = r'.\images'
# execution directory
print(os.getcwd())
os.chdir(target_directory)
# change directory
print(os.getcwd())
image_list: list = os.listdir(r'.\\')
for image_name in image_list:
print(image_name)
img = Image.open(image_name)
# 비율유지 안됨
# resize_img = img.resize((300, 500))
# resize_img.save(f'resize_{image_name}')
# 비율유지 됨
img.thumbnail((300, 500))
img.save(f'resize_{image_name}', quality=90)
# 공식사이트를 참고하자.
# https://pillow.readthedocs.io/
728x90
'python' 카테고리의 다른 글
python regular expression ( 정규 표현식 ) (0) | 2021.08.20 |
---|---|
python 메일보내기 (0) | 2021.08.19 |
python requests 헤더(header), 쿠키(cookie) 추가하기 (0) | 2021.08.19 |
python class (0) | 2021.08.19 |
python file rename, copy etc. (0) | 2021.08.19 |
Comments