88 lines
2.4 KiB
Markdown
88 lines
2.4 KiB
Markdown
---
|
||
name: image-processor
|
||
label: 이미지 처리
|
||
description: Python Pillow를 사용하여 이미지 리사이즈, 크롭, 워터마크, 포맷 변환을 수행합니다.
|
||
icon: \uEB9F
|
||
allowed-tools:
|
||
- folder_map
|
||
- file_read
|
||
- file_write
|
||
- process
|
||
- image_analyze
|
||
- format_convert
|
||
- file_manage
|
||
tabs: cowork
|
||
---
|
||
|
||
사용자의 요구에 맞게 이미지를 처리하세요.
|
||
## 실행 경로 선택 (Python 가능/불가)
|
||
- 먼저 `process`로 `python --version`을 확인하세요.
|
||
- Python 가능: 기존 Pillow 경로를 사용하세요.
|
||
- Python 불가: `image_analyze`로 이미지 상태를 점검하고, `file_manage`/`format_convert`/`file_write`로 가능한 변환 및 수동 처리 지침을 제공하세요.
|
||
|
||
|
||
## 사전 준비
|
||
먼저 Pillow 패키지가 설치되어 있<><EC9E88>지 확인하고, 없으면 설<><EC84A4><EFBFBD>하세요:
|
||
```
|
||
process: pip install Pillow
|
||
```
|
||
|
||
## 작업 절<><ECA088>
|
||
1. **요구사항 파악**: 처리할 이미지 파일과 원하는 작업 확인
|
||
2. **Python 스크립트 작성**: file_write로 .py 파일 생성
|
||
3. **스크립트 실행**: `process`로 Python 스크립<ED81AC><EBA6BD> 실행
|
||
4. **결과 확인**: 처리된 이미지 파일 경로를 사용자에게 안내
|
||
|
||
## 지원 기능
|
||
|
||
### 리사이즈
|
||
```python
|
||
from PIL import Image
|
||
img = Image.open('input.png')
|
||
img_resized = img.resize((800, 600)) # 고정 크기
|
||
# 또는 비율 유지
|
||
img.thumbnail((800, 800))
|
||
img.save('output.png')
|
||
```
|
||
|
||
### 크롭
|
||
```python
|
||
img = Image.open('input.png')
|
||
cropped = img.crop((left, top, right, bottom))
|
||
cropped.save('output.png')
|
||
```
|
||
|
||
### 워터마크
|
||
```python
|
||
from PIL import Image, ImageDraw, ImageFont
|
||
img = Image.open('input.png')
|
||
draw = ImageDraw.Draw(img)
|
||
draw.text((10, 10), "Watermark", fill=(255, 255, 255, 128))
|
||
img.save('output.png')
|
||
```
|
||
|
||
### 포맷 변환
|
||
```python
|
||
img = Image.open('input.png')
|
||
img.save('output.jpg', 'JPEG', quality=85)
|
||
img.save('output.webp', 'WEBP', quality=80)
|
||
```
|
||
|
||
### 배치 처리
|
||
```python
|
||
import glob
|
||
for path in glob.glob('*.png'):
|
||
img = Image.open(path)
|
||
img.thumbnail((800, 800))
|
||
img.save(f'resized_{path}')
|
||
```
|
||
|
||
## 추가 기능
|
||
- 회전/뒤집기 (rotate, transpose)
|
||
- 밝기/대비/선명도 조절 (ImageEnhance)
|
||
- 필터 적용 (ImageFilter: BLUR, SHARPEN, CONTOUR)
|
||
- 이미지 합성 (Image.paste, Image.alpha_composite)
|
||
- EXIF 정보 읽기
|
||
|
||
한국어로 안내하세요. 작업 폴더에 Python 스크립트와 결과 파일을 저장하세요.
|