[Refactor] 업로드 이미지 다운샘플 + JPEG 압축 (ImageIO)#34
Conversation
원본 그대로 업로드하던 것을 ImageIO 기반 다운샘플(max 2048px) + JPEG 압축(quality 0.8)으로 변경. - CGImageSourceCreateThumbnailAtIndex로 디코드 시점에 다운샘플하여 풀해상도 비트맵을 메모리에 올리지 않음 → 피크 메모리 절감 - kCGImageSourceCreateThumbnailWithTransform로 EXIF 회전 반영 - 위치/촬영시간은 압축 전 EXIF에서 이미 추출하므로 메타 손실 무관
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Walkthrough
Changes업로드 이미지 다운샘플 + JPEG 압축
Estimated code review effort: 2 (Simple) | ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@Rephoto_iOS/Features/Home/Domain/Services/PhotoMetadataExtractor.swift`:
- Around line 10-11: Move the image-processing implementation out of
PhotoMetadataExtractor in the Home Domain layer: the current Domain file is
importing ImageIO/UniformTypeIdentifiers and handling PhotosPickerItem
conversion, JPEG re-encoding, and temporary-file I/O, which violates the
pure-Domain boundary. Keep PhotoMetadataExtractor as a Domain protocol/use-case
contract only, and relocate the concrete implementation and all
platform/file/image handling into the Data layer, preserving the existing
symbols so callers continue to depend on the Domain abstraction.
- Around line 34-55: `PhotoMetadataExtractor`의 임시 JPEG 파일명 생성에서
`PhotosPickerItem.itemIdentifier`를 그대로 쓰는 부분이 문제이며, 슬래시가 포함되면
`appendingPathComponent`가 하위 경로로 해석되어 `compressed.write(to:)`가 실패할 수 있습니다.
`itemIdentifier`를 직접 파일명으로 쓰지 말고, `fileName`을 `UUID()` 기반 값이나 안전하게 sanitize된
문자열로 생성하도록 바꿔서 `destURL` 생성과 저장이 항상 유효한 단일 파일 경로가 되게 수정하세요.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 44f72039-7d87-4a3a-9465-fc0ba1f35050
📒 Files selected for processing (1)
Rephoto_iOS/Features/Home/Domain/Services/PhotoMetadataExtractor.swift
PhotosPickerItem.itemIdentifier가 'UUID/L0/001'처럼 슬래시를 포함하면 appendingPathComponent가 하위 경로로 해석해 write(to:)가 실패하고 사진이 누락됐다. 슬래시를 '_'로 치환.
✨ PR 유형
어떤 변경 사항이 있나요??
🛠️ 작업내용
리팩토링 계획 Step 7(성능 최적화) 의 "업로드 전 이미지 압축" 항목입니다.
원본 이미지를 그대로 업로드하던 방식을 ImageIO 기반 다운샘플 + JPEG 압축으로 교체했습니다.
CGImageSourceCreateThumbnailAtIndex로 디코드 시점에 다운샘플(max 2048px) → 풀해상도 비트맵을 메모리에 올리지 않아 피크 메모리 절감 (UIImage(data:).jpegData()는 4000x3000 기준 ~36MB 비트맵이 메모리에 튐)kCGImageSourceCreateThumbnailWithTransform로 EXIF 회전 반영 → 세로 사진이 눕는 문제 방지#if DEBUG압축 전후 용량 로그 추가 (압축률 확인용)📋 추후 진행 상황
📌 리뷰 포인트
...WithTransform)이 의도대로 동작하는지✅ Checklist
Closes #33
Summary by CodeRabbit