📝 Issue Description
기존 OpenAI LLM 기반 홍보물 콘텐츠 생성(SpringAIPromotionProvider)에 HTML 폰트-이미지 합성 기능을 추가하여, 텍스트가 오버레이된 완성형 홍보물 이미지를 자동 생성하는 기능을 구현합니다.
🎯 Goals
🔧 Technical Requirements
Environment
- Java 21
- Gradle
- Spring Boot 3.x
- Spring AI (OpenAI integration)
Dependencies to Add
dependencies {
// Playwright for HTML to PNG conversion
implementation 'com.microsoft.playwright:playwright:1.40.0'
// WebFlux for async image download
implementation 'org.springframework.boot:spring-boot-starter-webflux'
// Image processing utilities
implementation 'org.apache.commons:commons-imaging:1.0.0-alpha5'
// Async processing
implementation 'org.springframework.boot:spring-boot-starter-web'
}
📋 Implementation Tasks
Phase 1: Core Infrastructure
Phase 2: Browser Management
Phase 3: Integration & Enhancement
Phase 4: Performance & Monitoring
📐 HTML Template Design
Layout Types
public enum PromotionLayoutType {
OVERLAY_CENTER, // 중앙 텍스트 오버레이
OVERLAY_BOTTOM, // 하단 정보 배치
SPLIT_LAYOUT, // 좌우 분할 레이아웃
CARD_STYLE // 카드형 디자인
}
Template Structure
<div class="promotion-container">
<div class="spot-name">{{ spotName }}</div>
<div class="title">{{ suggestedTitle }}</div>
<div class="tags">
<span class="tag">{{ recommendedTag }}</span>
</div>
<div class="emotions">{{ emotions }}</div>
</div>
⚙️ Configuration
application.yml
thumbnail:
image:
default-width: 1200
default-height: 630 # SNS 최적 비율 (1.91:1)
max-file-size: 5MB
quality: 85
timeout: 30s
template:
font-family: "Noto Sans KR"
primary-color: "#FFFFFF"
shadow-color: "rgba(0,0,0,0.8)"
browser:
pool-size: 3
headless: true
timeout: 10s
🔄 Data Flow
PromotionRequest
↓
OpenAI LLM → PromotionResult
↓
mainImageUrl → Download Background Image
↓
PromotionResult → HTML Template
↓
HTML → Playwright → Transparent Text PNG
↓
Background + Text → BufferedImage Composite
↓
Final Thumbnail PNG
📊 Expected Performance
Target Metrics
- 전체 프로세스: 3-6초 (최적화 후)
- LLM 응답: 2-5초 (기존)
- 이미지 다운로드: 0.5-2초
- HTML → PNG 변환: 1-2초
- 이미지 합성: 0.2-0.5초
Performance Optimizations
- 브라우저 인스턴스 재사용으로 초기화 시간 단축
- 이미지 다운로드 캐싱
- 비동기 처리로 사용자 응답성 향상
🧪 Testing Strategy
Unit Tests
Integration Tests
Test Data
// 테스트용 PromotionResult 샘플
PromotionResult testData = new PromotionResult(
"맛있는 카페",
"https://example.com/image.jpg",
List.of("커피", "디저트", "분위기"),
List.of("따뜻함", "아늑함"),
"감성 가득한 동네 카페에서의 특별한 시간",
"직접 로스팅한 원두로 내린 커피가 일품입니다. 아늑한 인테리어와 친절한 사장님이 기억에 남아요. 디저트도 맛있어서 재방문 의사 100%입니다."
);
🚨 Error Handling & Fallback
Fallback Strategy
- LLM 실패: 기존
createFallbackPromotion() 사용
- 이미지 다운로드 실패: 기본 배경 이미지 적용
- HTML 렌더링 실패: 텍스트만으로 간단한 이미지 생성
- 합성 실패: 원본 배경 이미지 반환
Error Monitoring
- 각 단계별 실패율 추적
- 실패 원인별 분류 및 로깅
- 알림 및 모니터링 대시보드 연동
🔍 Definition of Done
📚 References
Estimated Timeline: 2-3 weeks
Priority: High
Labels: enhancement, feature, backend, image-processing
📝 Issue Description
기존 OpenAI LLM 기반 홍보물 콘텐츠 생성(
SpringAIPromotionProvider)에 HTML 폰트-이미지 합성 기능을 추가하여, 텍스트가 오버레이된 완성형 홍보물 이미지를 자동 생성하는 기능을 구현합니다.🎯 Goals
🔧 Technical Requirements
Environment
Dependencies to Add
📋 Implementation Tasks
Phase 1: Core Infrastructure
Task 1.1:
PromotionImageService구현Task 1.2:
ImageDownloadService구현Task 1.3:
HtmlTemplateService구현PromotionResult→ HTML 템플릿 변환Phase 2: Browser Management
Task 2.1:
PlaywrightBrowserPool구현Task 2.2: 투명 배경 텍스트 이미지 생성
setOmitBackground(true)적용Phase 3: Integration & Enhancement
Task 3.1:
SpringAIPromotionProvider확장PromotionImageResult응답 구조 정의Task 3.2: 비동기 처리 구현
@Async기반 백그라운드 처리taskId기반)CompletableFuture활용Phase 4: Performance & Monitoring
Task 4.1: 성능 최적화
Task 4.2: 모니터링 및 로깅
📐 HTML Template Design
Layout Types
Template Structure
⚙️ Configuration
application.yml
🔄 Data Flow
📊 Expected Performance
Target Metrics
Performance Optimizations
🧪 Testing Strategy
Unit Tests
Integration Tests
PromotionResult입력 시나리오Test Data
🚨 Error Handling & Fallback
Fallback Strategy
createFallbackPromotion()사용Error Monitoring
🔍 Definition of Done
📚 References
Estimated Timeline: 2-3 weeks
Priority: High
Labels:
enhancement,feature,backend,image-processing