Hello. { #Somebody }
썸네일(thumbnail) 이미지 만들기
간단하게 파이썬으로 썸네일 이미지 만들 수 있는 방법에 대해서 기록합니다.
pillow 모듈 설치
pip install pillow
소스 코드
import os
from PIL import Image
def main():
size = (512, 512)
imageFile = "sample_image.jpg"
filePath = ("%s_resized.%s" % (os.path.splitext(imageFile)[0], "jpg"))
try:
image = Image.open(imageFile)
image.thumbnail(size)
image.save(filePath, 'JPEG', quality=100)
except IOError:
print("Failed to create thumbnail of %s" % imageFile)
if __name__ == '__main__':
main()
Python is simple
Bye. { #Somebody }
'Programming > python' 카테고리의 다른 글
[python] 스크린샷 프로그램 만들기 (with Hotkey) (0) | 2023.09.16 |
---|---|
[python] 이미지 모자이크 처리하기 (image blur) (0) | 2023.09.15 |
[python] 터미널/커맨드 화면 출력 글자 색상 변경 해보기 (Text Color) (0) | 2023.09.02 |
[python] 윈도우 특정 프로그램 화면 스크린샷을 텔레그램으로 보내기 (0) | 2023.08.26 |
[python] 이미지 파일 텔레그램으로 전송하기 (0) | 2023.08.26 |