-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimage_proc.py
More file actions
35 lines (27 loc) · 1.01 KB
/
image_proc.py
File metadata and controls
35 lines (27 loc) · 1.01 KB
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
32
33
34
35
"""
이미지 전처리 및 URL 캡처 도구
"""
import io
from PIL import Image
class ImageProcessor:
"""이미지 전처리 유틸리티"""
@staticmethod
def resize_image(image_path: str, max_size: tuple = (1920, 1080)) -> bytes:
"""이미지 크기를 조정합니다."""
with Image.open(image_path) as img:
img.thumbnail(max_size, Image.Resampling.LANCZOS)
buffer = io.BytesIO()
img.save(buffer, format="PNG")
return buffer.getvalue()
@staticmethod
def convert_to_base64(image_bytes: bytes) -> str:
"""이미지를 base64로 인코딩합니다."""
import base64
return base64.b64encode(image_bytes).decode("utf-8")
class URLCapture:
"""URL 스크린샷 캡처 도구"""
@staticmethod
async def capture(url: str, viewport_size: tuple = (1920, 1080)) -> bytes:
"""URL의 스크린샷을 캡처합니다."""
# TODO: Playwright/Selenium을 사용한 스크린샷 캡처 구현
pass