일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- SQL
- Google Excel
- PANDAS
- Google Spreadsheet
- google apps script
- c#
- 파이썬
- list
- Kotlin
- django
- math
- Python
- Mac
- Java
- Apache
- PySpark
- dataframe
- numpy
- array
- matplotlib
- Tkinter
- PostgreSQL
- Redshift
- Excel
- gas
- Github
- string
- hive
- GIT
- Today
- Total
목록PIL (5)
달나라 노트
Python에서는 PIL module을 이용하여 화면을 캡쳐할 수 있습니다. from PIL import ImageGrab# capture entire screenimg = ImageGrab.grab()img.show() 위처럼 하면 화면 전체를 캡쳐할 수 있습니다. from PIL import ImageGrab# capture top-left rectangle with size 638px wide by 312px tallimg = ImageGrab.grab(bbox=(0, 0, 538, 312))img.show() 위처럼 화면 캡쳐 영역의 크기를 조절할 수도 있습니다. 캡쳐는 직사각형으로 할 수 있으며, bbox에 담겨진 4개의 인자는 각각 직사각형의 꼭지점 좌표를 의미합니다.bbox=(x1, ..
PIL module을 이용해서 이미지 위에 텍스트를 넣어봅시다. 단계는 다음과 같습니다. 1. 배경이 검은 색의 이미지를 생성한 후 2. 이 이미지를 불러와 흰색의 글씨를 쓴다. 코드를 봅시다. import numpy as np import cv2 from PIL import Image, ImageDraw img_file = 'img_black.png' img_file_with_text = 'img_black_with_text.png' # create black img arr_black = np.zeros(shape=(1080, 1080, 3), dtype=int) cv2.imwrite(img_file, arr_black) # 검정색 image 생성 # write letter on img cls_img ..
matplotlib는 굉장히 재미있는 기능들을 제공하는데 그 중에선 image 파일을 읽어서 그래프로 나타내주는 기능을 제공합니다. 제가 이전에 먹었던 녹차빙수 사진을 한번 matplotlib를 이용해서 그래프 위에 나타내보겠습니다. import matplotlib.pyplot as plt import matplotlib.image as img img_test = img.imread('greentea_ice_flakes.png') plt.imshow(img_test) plt.show() directory 구조는 위와 같습니다. pyplot.py 파일에 위 예시코드가 적혀있으며 greentea_ice_flakes.png 파일이 바로 제가 먹었던 녹차빙수 사진입니다. - img_test = img.imrea..
Python을 이용해 image 파일을 pdf로 변환하는 방법을 알아봅시다. pip install PIL pip install Pillow 사용되는 라이브러리는 PIL 입니다. PIL이 간혹 설치가 제대로 되지 않는 경우가 있을 수 있는데 그럴 땐 Pillow 패키지를 설치합시다. (Pillow 패키지를 설치해도 PIL 라이브러리는 이용할 수 있습니다.) from PIL import Image img = Image.open(r'test/img_test_1.png') img_rgb = img.convert('RGB') img_rgb.save('test/pdf_test_1.pdf') 위 예시는 test directory에 있는 img_test_1.png라는 이미지파일을 test directory안에 pdf_..